From a7f18608539f8c5db6c2dfeeebed890f811d99b1 Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 3 May 2023 12:34:15 +0200 Subject: [PATCH 1/4] Remove app create commands --- lib/shopify_cli/commands/app.rb | 1 - lib/shopify_cli/commands/app/create.rb | 28 ----- lib/shopify_cli/commands/app/create/node.rb | 40 -------- lib/shopify_cli/commands/app/create/php.rb | 37 ------- lib/shopify_cli/commands/app/create/rails.rb | 42 -------- lib/shopify_cli/messages/messages.rb | 101 ------------------- 6 files changed, 249 deletions(-) delete mode 100644 lib/shopify_cli/commands/app/create.rb delete mode 100644 lib/shopify_cli/commands/app/create/node.rb delete mode 100644 lib/shopify_cli/commands/app/create/php.rb delete mode 100644 lib/shopify_cli/commands/app/create/rails.rb diff --git a/lib/shopify_cli/commands/app.rb b/lib/shopify_cli/commands/app.rb index 9050c59e89..24cc1b5d21 100644 --- a/lib/shopify_cli/commands/app.rb +++ b/lib/shopify_cli/commands/app.rb @@ -4,7 +4,6 @@ module ShopifyCLI module Commands class App < ShopifyCLI::Command subcommand :Connect, "connect", "shopify_cli/commands/app/connect" - subcommand :Create, "create", "shopify_cli/commands/app/create" subcommand :Deploy, "deploy", "shopify_cli/commands/app/deploy" subcommand :Open, "open", "shopify_cli/commands/app/open" subcommand :Serve, "serve", "shopify_cli/commands/app/serve" diff --git a/lib/shopify_cli/commands/app/create.rb b/lib/shopify_cli/commands/app/create.rb deleted file mode 100644 index c499a87dec..0000000000 --- a/lib/shopify_cli/commands/app/create.rb +++ /dev/null @@ -1,28 +0,0 @@ -module ShopifyCLI - module Commands - class App - class Create < ShopifyCLI::Command - subcommand :Rails, "rails", "shopify_cli/commands/app/create/rails" - subcommand :PHP, "php", "shopify_cli/commands/app/create/php" - subcommand :Node, "node", "shopify_cli/commands/app/create/node" - - def call(_args, _command_name) - @ctx.puts(self.class.help) - end - - def self.help - ShopifyCLI::Context.message("core.app.create.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME) - end - - def self.call_help(*) - output = help - if respond_to?(:extended_help) - output += "\n" - output += extended_help - end - @ctx.puts(output) - end - end - end - end -end diff --git a/lib/shopify_cli/commands/app/create/node.rb b/lib/shopify_cli/commands/app/create/node.rb deleted file mode 100644 index 51a8d68ee6..0000000000 --- a/lib/shopify_cli/commands/app/create/node.rb +++ /dev/null @@ -1,40 +0,0 @@ -module ShopifyCLI - module Commands - class App - class Create - class Node < ShopifyCLI::Command::AppSubCommand - prerequisite_task :ensure_authenticated - prerequisite_task :ensure_git_dependency - - recommend_default_node_range - recommend_default_ruby_range - - options do |parser, flags| - parser.on("--name=NAME") { |t| flags[:name] = t } - parser.on("--organization-id=ID") { |id| flags[:organization_id] = id } - parser.on("--store-domain=MYSHOPIFYDOMAIN") { |url| flags[:store_domain] = url } - parser.on("--type=APPTYPE") { |type| flags[:type] = type } - parser.on("--verbose") { flags[:verbose] = true } - end - - def call(*) - Services::App::Create::NodeService.call( - name: options.flags[:name], - organization_id: options.flags[:organization_id], - store_domain: options.flags[:store_domain], - type: options.flags[:type], - verbose: !options.flags[:verbose].nil?, - context: @ctx - ) - end - - class << self - def help - ShopifyCLI::Context.message("core.app.create.node.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME) - end - end - end - end - end - end -end diff --git a/lib/shopify_cli/commands/app/create/php.rb b/lib/shopify_cli/commands/app/create/php.rb deleted file mode 100644 index 8fd5172e7b..0000000000 --- a/lib/shopify_cli/commands/app/create/php.rb +++ /dev/null @@ -1,37 +0,0 @@ -module ShopifyCLI - module Commands - class App - class Create - class PHP < ShopifyCLI::Command::AppSubCommand - prerequisite_task :ensure_authenticated - prerequisite_task :ensure_git_dependency - - options do |parser, flags| - parser.on("--name=NAME") { |name| flags[:name] = name } - parser.on("--organization-id=ID") { |organization_id| flags[:organization_id] = organization_id } - parser.on("--store-domain=MYSHOPIFYDOMAIN") { |url| flags[:store_domain] = url } - parser.on("--type=APPTYPE") { |type| flags[:type] = type } - parser.on("--verbose") { flags[:verbose] = true } - end - - def call(*) - Services::App::Create::PHPService.call( - name: options.flags[:name], - organization_id: options.flags[:organization_id], - store_domain: options.flags[:store_domain], - type: options.flags[:type], - verbose: !options.flags[:verbose].nil?, - context: @ctx - ) - end - - class << self - def help - ShopifyCLI::Context.message("core.app.create.php.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME) - end - end - end - end - end - end -end diff --git a/lib/shopify_cli/commands/app/create/rails.rb b/lib/shopify_cli/commands/app/create/rails.rb deleted file mode 100644 index 7a004c81b6..0000000000 --- a/lib/shopify_cli/commands/app/create/rails.rb +++ /dev/null @@ -1,42 +0,0 @@ -module ShopifyCLI - module Commands - class App - class Create - class Rails < ShopifyCLI::Command::AppSubCommand - prerequisite_task :ensure_authenticated - prerequisite_task :ensure_git_dependency - - recommend_default_ruby_range - recommend_default_node_range - - options do |parser, flags| - parser.on("--name=NAME") { |t| flags[:name] = t } - parser.on("--organization-id=ID") { |id| flags[:organization_id] = id } - parser.on("--store-domain=MYSHOPIFYDOMAIN") { |url| flags[:store_domain] = url } - parser.on("--type=APPTYPE") { |type| flags[:type] = type } - parser.on("--db=DB") { |db| flags[:db] = db } - parser.on("--rails-opts=RAILSOPTS") { |opts| flags[:rails_opts] = opts } - end - - def call(*) - Services::App::Create::RailsService.call( - name: options.flags[:name], - organization_id: options.flags[:organization_id], - store_domain: options.flags[:store_domain], - type: options.flags[:type], - db: options.flags[:db], - rails_opts: options.flags[:rails_opts], - context: @ctx - ) - end - - class << self - def help - ShopifyCLI::Context.message("core.app.create.rails.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME) - end - end - end - end - end - end -end diff --git a/lib/shopify_cli/messages/messages.rb b/lib/shopify_cli/messages/messages.rb index 5569328411..f1d3a71db6 100644 --- a/lib/shopify_cli/messages/messages.rb +++ b/lib/shopify_cli/messages/messages.rb @@ -46,107 +46,6 @@ module Messages The project type %s doesn't represent an app. MESSAGE }, - create: { - type_required_error: "", - invalid_type: "The type %s is not supported. The only supported types are"\ - " {{command:[ rails | node | php ]}}", - help: <<~HELP, - {{command:%s app create}}: Creates a new project in a subdirectory. - Usage: {{command:%s app create [ rails | node | php ]}} - HELP - rails: { - help: <<~HELP, - {{command:%s app create rails}}: Creates a ruby on rails app. - Usage: {{command:%s app create rails}} - Options: - {{command:--name=NAME}} App name. Any string. - {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization. - {{command:--store-domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store. - {{command:--db=DB}} Database type. Must be one of: mysql, postgresql, sqlite3, oracle, frontbase, ibm_db, sqlserver, jdbcmysql, jdbcsqlite3, jdbcpostgresql, jdbc. - {{command:--rails-opts=RAILSOPTS}} Additional options. Must be a string containing one or more valid Rails options, separated by spaces. - HELP - - error: { - invalid_ruby_version: "This project requires a Ruby version ~> 2.5 or Ruby 3.0.", - dir_exists: "Project directory %s already exists. Please use a different name.", - install_failure: "Error installing %s gem", - node_required: "node is required to create a rails project. Download at https://nodejs.org/en/download.", - node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \ - "per the instructions at https://nodejs.org/en.", - yarn_required: "yarn is required to create a rails project. Download at " \ - "https://classic.yarnpkg.com/en/docs/install.", - yarn_version_failure: "Failed to get the current yarn version. Please make sure it is " \ - "installed as per the instructions at https://classic.yarnpkg.com/en/docs/install.", - }, - - info: { - open_new_shell: "{{*}} {{yellow:After installing %s, please open a new Command Prompt or PowerShell " \ - "window to continue.}}", - }, - installing_bundler: "Installing bundler…", - generating_app: "Generating new rails app project in %s…", - adding_shopify_gem: "{{v}} Adding shopify_app gem…", - node_version: "node %s", - yarn_version: "yarn %s", - running_bundle_install: "Running bundle install…", - running_generator: "Running shopify_app generator…", - running_migrations: "Running migrations…", - running_webpacker_install: "Running webpacker:install…", - }, - node: { - help: <<~HELP, - {{command:%s app create node}}: Creates an embedded nodejs app. - Usage: {{command:%s app create node}} - Options: - {{command:--name=NAME}} App name. Any string. - {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization. - {{command:--store-domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store. - HELP - error: { - node_required: "node is required to create an app project. Download at https://nodejs.org/en/download.", - npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.", - npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \ - "the instructions at https://www.npmjs.com/get-npm.", - }, - node_version: "node %s", - npm_version: "npm %s", - }, - php: { - help: <<~HELP, - {{command:%s app create php}}: Creates an embedded PHP app. - Usage: {{command:%s app create php}} - Options: - {{command:--name=NAME}} App name. Any string. - {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization. - {{command:--store-domain=MYSHOPIFYDOMAIN}} Development store URL. Must be an existing development store. - {{command:--type=APPTYPE}} Whether this app is public or custom. - {{command:--verbose}} Output verbose information when installing dependencies. - HELP - - error: { - php_required: <<~VERSION, - PHP is required to create an app project. For installation instructions, visit: - {{underline:https://www.php.net/manual/en/install.php}} - VERSION - php_version_failure: <<~VERSION, - Failed to get the current PHP version. Please make sure it is installed as per the instructions at: - {{underline:https://www.php.net/manual/en/install.php.}} - VERSION - php_version_too_low: "Your PHP version is too low. Please use version %s or higher.", - composer_required: <<~COMPOSER, - Composer is required to create an app project. Download at: - {{underline:https://getcomposer.org/download/}} - COMPOSER - npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.", - app_setup: "Failed to set up the app", - }, - - php_version: "PHP %s", - npm_version: "npm %s", - app_setting_up: "Setting up app…", - app_set_up: "App is now set up", - }, - }, deploy: { help: <<~HELP, Deploy the current app to a hosting service. Heroku ({{underline:https://www.heroku.com}}) is currently the only option, but more will be added in the future. From af4d6e92bddcb0905f8e43c78ccca30bcadc0761 Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 3 May 2023 12:39:00 +0200 Subject: [PATCH 2/4] Revert "Remove app create commands" This reverts commit a7f18608539f8c5db6c2dfeeebed890f811d99b1. --- lib/shopify_cli/commands/app.rb | 1 + lib/shopify_cli/commands/app/create.rb | 28 +++++ lib/shopify_cli/commands/app/create/node.rb | 40 ++++++++ lib/shopify_cli/commands/app/create/php.rb | 37 +++++++ lib/shopify_cli/commands/app/create/rails.rb | 42 ++++++++ lib/shopify_cli/messages/messages.rb | 101 +++++++++++++++++++ 6 files changed, 249 insertions(+) create mode 100644 lib/shopify_cli/commands/app/create.rb create mode 100644 lib/shopify_cli/commands/app/create/node.rb create mode 100644 lib/shopify_cli/commands/app/create/php.rb create mode 100644 lib/shopify_cli/commands/app/create/rails.rb diff --git a/lib/shopify_cli/commands/app.rb b/lib/shopify_cli/commands/app.rb index 24cc1b5d21..9050c59e89 100644 --- a/lib/shopify_cli/commands/app.rb +++ b/lib/shopify_cli/commands/app.rb @@ -4,6 +4,7 @@ module ShopifyCLI module Commands class App < ShopifyCLI::Command subcommand :Connect, "connect", "shopify_cli/commands/app/connect" + subcommand :Create, "create", "shopify_cli/commands/app/create" subcommand :Deploy, "deploy", "shopify_cli/commands/app/deploy" subcommand :Open, "open", "shopify_cli/commands/app/open" subcommand :Serve, "serve", "shopify_cli/commands/app/serve" diff --git a/lib/shopify_cli/commands/app/create.rb b/lib/shopify_cli/commands/app/create.rb new file mode 100644 index 0000000000..c499a87dec --- /dev/null +++ b/lib/shopify_cli/commands/app/create.rb @@ -0,0 +1,28 @@ +module ShopifyCLI + module Commands + class App + class Create < ShopifyCLI::Command + subcommand :Rails, "rails", "shopify_cli/commands/app/create/rails" + subcommand :PHP, "php", "shopify_cli/commands/app/create/php" + subcommand :Node, "node", "shopify_cli/commands/app/create/node" + + def call(_args, _command_name) + @ctx.puts(self.class.help) + end + + def self.help + ShopifyCLI::Context.message("core.app.create.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME) + end + + def self.call_help(*) + output = help + if respond_to?(:extended_help) + output += "\n" + output += extended_help + end + @ctx.puts(output) + end + end + end + end +end diff --git a/lib/shopify_cli/commands/app/create/node.rb b/lib/shopify_cli/commands/app/create/node.rb new file mode 100644 index 0000000000..51a8d68ee6 --- /dev/null +++ b/lib/shopify_cli/commands/app/create/node.rb @@ -0,0 +1,40 @@ +module ShopifyCLI + module Commands + class App + class Create + class Node < ShopifyCLI::Command::AppSubCommand + prerequisite_task :ensure_authenticated + prerequisite_task :ensure_git_dependency + + recommend_default_node_range + recommend_default_ruby_range + + options do |parser, flags| + parser.on("--name=NAME") { |t| flags[:name] = t } + parser.on("--organization-id=ID") { |id| flags[:organization_id] = id } + parser.on("--store-domain=MYSHOPIFYDOMAIN") { |url| flags[:store_domain] = url } + parser.on("--type=APPTYPE") { |type| flags[:type] = type } + parser.on("--verbose") { flags[:verbose] = true } + end + + def call(*) + Services::App::Create::NodeService.call( + name: options.flags[:name], + organization_id: options.flags[:organization_id], + store_domain: options.flags[:store_domain], + type: options.flags[:type], + verbose: !options.flags[:verbose].nil?, + context: @ctx + ) + end + + class << self + def help + ShopifyCLI::Context.message("core.app.create.node.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME) + end + end + end + end + end + end +end diff --git a/lib/shopify_cli/commands/app/create/php.rb b/lib/shopify_cli/commands/app/create/php.rb new file mode 100644 index 0000000000..8fd5172e7b --- /dev/null +++ b/lib/shopify_cli/commands/app/create/php.rb @@ -0,0 +1,37 @@ +module ShopifyCLI + module Commands + class App + class Create + class PHP < ShopifyCLI::Command::AppSubCommand + prerequisite_task :ensure_authenticated + prerequisite_task :ensure_git_dependency + + options do |parser, flags| + parser.on("--name=NAME") { |name| flags[:name] = name } + parser.on("--organization-id=ID") { |organization_id| flags[:organization_id] = organization_id } + parser.on("--store-domain=MYSHOPIFYDOMAIN") { |url| flags[:store_domain] = url } + parser.on("--type=APPTYPE") { |type| flags[:type] = type } + parser.on("--verbose") { flags[:verbose] = true } + end + + def call(*) + Services::App::Create::PHPService.call( + name: options.flags[:name], + organization_id: options.flags[:organization_id], + store_domain: options.flags[:store_domain], + type: options.flags[:type], + verbose: !options.flags[:verbose].nil?, + context: @ctx + ) + end + + class << self + def help + ShopifyCLI::Context.message("core.app.create.php.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME) + end + end + end + end + end + end +end diff --git a/lib/shopify_cli/commands/app/create/rails.rb b/lib/shopify_cli/commands/app/create/rails.rb new file mode 100644 index 0000000000..7a004c81b6 --- /dev/null +++ b/lib/shopify_cli/commands/app/create/rails.rb @@ -0,0 +1,42 @@ +module ShopifyCLI + module Commands + class App + class Create + class Rails < ShopifyCLI::Command::AppSubCommand + prerequisite_task :ensure_authenticated + prerequisite_task :ensure_git_dependency + + recommend_default_ruby_range + recommend_default_node_range + + options do |parser, flags| + parser.on("--name=NAME") { |t| flags[:name] = t } + parser.on("--organization-id=ID") { |id| flags[:organization_id] = id } + parser.on("--store-domain=MYSHOPIFYDOMAIN") { |url| flags[:store_domain] = url } + parser.on("--type=APPTYPE") { |type| flags[:type] = type } + parser.on("--db=DB") { |db| flags[:db] = db } + parser.on("--rails-opts=RAILSOPTS") { |opts| flags[:rails_opts] = opts } + end + + def call(*) + Services::App::Create::RailsService.call( + name: options.flags[:name], + organization_id: options.flags[:organization_id], + store_domain: options.flags[:store_domain], + type: options.flags[:type], + db: options.flags[:db], + rails_opts: options.flags[:rails_opts], + context: @ctx + ) + end + + class << self + def help + ShopifyCLI::Context.message("core.app.create.rails.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME) + end + end + end + end + end + end +end diff --git a/lib/shopify_cli/messages/messages.rb b/lib/shopify_cli/messages/messages.rb index f1d3a71db6..5569328411 100644 --- a/lib/shopify_cli/messages/messages.rb +++ b/lib/shopify_cli/messages/messages.rb @@ -46,6 +46,107 @@ module Messages The project type %s doesn't represent an app. MESSAGE }, + create: { + type_required_error: "", + invalid_type: "The type %s is not supported. The only supported types are"\ + " {{command:[ rails | node | php ]}}", + help: <<~HELP, + {{command:%s app create}}: Creates a new project in a subdirectory. + Usage: {{command:%s app create [ rails | node | php ]}} + HELP + rails: { + help: <<~HELP, + {{command:%s app create rails}}: Creates a ruby on rails app. + Usage: {{command:%s app create rails}} + Options: + {{command:--name=NAME}} App name. Any string. + {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization. + {{command:--store-domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store. + {{command:--db=DB}} Database type. Must be one of: mysql, postgresql, sqlite3, oracle, frontbase, ibm_db, sqlserver, jdbcmysql, jdbcsqlite3, jdbcpostgresql, jdbc. + {{command:--rails-opts=RAILSOPTS}} Additional options. Must be a string containing one or more valid Rails options, separated by spaces. + HELP + + error: { + invalid_ruby_version: "This project requires a Ruby version ~> 2.5 or Ruby 3.0.", + dir_exists: "Project directory %s already exists. Please use a different name.", + install_failure: "Error installing %s gem", + node_required: "node is required to create a rails project. Download at https://nodejs.org/en/download.", + node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \ + "per the instructions at https://nodejs.org/en.", + yarn_required: "yarn is required to create a rails project. Download at " \ + "https://classic.yarnpkg.com/en/docs/install.", + yarn_version_failure: "Failed to get the current yarn version. Please make sure it is " \ + "installed as per the instructions at https://classic.yarnpkg.com/en/docs/install.", + }, + + info: { + open_new_shell: "{{*}} {{yellow:After installing %s, please open a new Command Prompt or PowerShell " \ + "window to continue.}}", + }, + installing_bundler: "Installing bundler…", + generating_app: "Generating new rails app project in %s…", + adding_shopify_gem: "{{v}} Adding shopify_app gem…", + node_version: "node %s", + yarn_version: "yarn %s", + running_bundle_install: "Running bundle install…", + running_generator: "Running shopify_app generator…", + running_migrations: "Running migrations…", + running_webpacker_install: "Running webpacker:install…", + }, + node: { + help: <<~HELP, + {{command:%s app create node}}: Creates an embedded nodejs app. + Usage: {{command:%s app create node}} + Options: + {{command:--name=NAME}} App name. Any string. + {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization. + {{command:--store-domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store. + HELP + error: { + node_required: "node is required to create an app project. Download at https://nodejs.org/en/download.", + npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.", + npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \ + "the instructions at https://www.npmjs.com/get-npm.", + }, + node_version: "node %s", + npm_version: "npm %s", + }, + php: { + help: <<~HELP, + {{command:%s app create php}}: Creates an embedded PHP app. + Usage: {{command:%s app create php}} + Options: + {{command:--name=NAME}} App name. Any string. + {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization. + {{command:--store-domain=MYSHOPIFYDOMAIN}} Development store URL. Must be an existing development store. + {{command:--type=APPTYPE}} Whether this app is public or custom. + {{command:--verbose}} Output verbose information when installing dependencies. + HELP + + error: { + php_required: <<~VERSION, + PHP is required to create an app project. For installation instructions, visit: + {{underline:https://www.php.net/manual/en/install.php}} + VERSION + php_version_failure: <<~VERSION, + Failed to get the current PHP version. Please make sure it is installed as per the instructions at: + {{underline:https://www.php.net/manual/en/install.php.}} + VERSION + php_version_too_low: "Your PHP version is too low. Please use version %s or higher.", + composer_required: <<~COMPOSER, + Composer is required to create an app project. Download at: + {{underline:https://getcomposer.org/download/}} + COMPOSER + npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.", + app_setup: "Failed to set up the app", + }, + + php_version: "PHP %s", + npm_version: "npm %s", + app_setting_up: "Setting up app…", + app_set_up: "App is now set up", + }, + }, deploy: { help: <<~HELP, Deploy the current app to a hosting service. Heroku ({{underline:https://www.heroku.com}}) is currently the only option, but more will be added in the future. From 0c5511faa6e76997c17d754ced99f52ae66b4b11 Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 3 May 2023 12:40:00 +0200 Subject: [PATCH 3/4] Remove app/extension create subcommand --- lib/project_types/extension/cli.rb | 1 - lib/shopify_cli/commands/app.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/project_types/extension/cli.rb b/lib/project_types/extension/cli.rb index 5a293db18e..88e5ac1dd0 100644 --- a/lib/project_types/extension/cli.rb +++ b/lib/project_types/extension/cli.rb @@ -19,7 +19,6 @@ class Project < ShopifyCLI::ProjectType class Command < ShopifyCLI::Command::ProjectCommand autoload :ExtensionCommand, Project.project_filepath("commands/extension_command") - subcommand :Create, "create", Project.project_filepath("commands/create") subcommand :Register, "register", Project.project_filepath("commands/register") subcommand :Info, "info", Project.project_filepath("commands/info") subcommand :Connect, "connect", Project.project_filepath("commands/connect") diff --git a/lib/shopify_cli/commands/app.rb b/lib/shopify_cli/commands/app.rb index 9050c59e89..24cc1b5d21 100644 --- a/lib/shopify_cli/commands/app.rb +++ b/lib/shopify_cli/commands/app.rb @@ -4,7 +4,6 @@ module ShopifyCLI module Commands class App < ShopifyCLI::Command subcommand :Connect, "connect", "shopify_cli/commands/app/connect" - subcommand :Create, "create", "shopify_cli/commands/app/create" subcommand :Deploy, "deploy", "shopify_cli/commands/app/deploy" subcommand :Open, "open", "shopify_cli/commands/app/open" subcommand :Serve, "serve", "shopify_cli/commands/app/serve" From b521836e03e0adb94d9b4b9903498ac80287c368 Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 3 May 2023 13:33:08 +0200 Subject: [PATCH 4/4] Remove extension create tests --- .../extension/commands/create_test.rb | 102 ------------------ 1 file changed, 102 deletions(-) delete mode 100644 test/project_types/extension/commands/create_test.rb diff --git a/test/project_types/extension/commands/create_test.rb b/test/project_types/extension/commands/create_test.rb deleted file mode 100644 index b891abd061..0000000000 --- a/test/project_types/extension/commands/create_test.rb +++ /dev/null @@ -1,102 +0,0 @@ -# frozen_string_literal: true -require "test_helper" -require "project_types/extension/extension_test_helpers" - -module Extension - module Commands - class CreateTest < MiniTest::Test - include ExtensionTestHelpers::Stubs::GetApp - - def setup - super - @name = "My Ext" - @directory_name = "my_ext" - - ShopifyCLI::ProjectType.load_type(:extension) - - ExtensionTestHelpers.fake_extension_project(with_mocks: true) - @specification_handler = ExtensionTestHelpers.test_specification_handler - - @app = Models::App.new(title: "Fake", api_key: "1234", secret: "4567", business_name: "Fake Business") - stub_get_app(api_key: "1234", app: @app) - - ShopifyCLI::Tasks::EnsureAuthenticated.stubs(:call) - end - - def test_prints_help - io = capture_io { run_cmd("extension create --help") } - assert_message_output(io: io, expected_content: [Extension::Command::Create.help]) - end - - def test_create_aborts_if_the_directory_already_exists - ShopifyCLI::Shopifolk.stubs(:check).returns(false) - ShopifyCLI::Feature.stubs(:enabled?).with(:extension_server_beta).returns(false) - - Dir.expects(:exist?).with(@directory_name).returns(true).once - Models::SpecificationHandlers::Default.any_instance.expects(:create).never - - io = capture_io_and_assert_raises(ShopifyCLI::Abort) do - run_create(%W(extension --name=#{@name} --type=#{@specification_handler.identifier} - --api-key=#{@app.api_key})) - end - - assert_message_output(io: io, expected_content: [ - @context.message("create.errors.directory_exists", @directory_name), - ]) - end - - def test_runs_type_create_and_writes_project_files - ShopifyCLI::Shopifolk.stubs(:check).returns(false) - ShopifyCLI::Feature.stubs(:enabled?).with(:extension_server_beta).returns(false) - - Dir.expects(:exist?).with(@directory_name).returns(false).once - Models::SpecificationHandlers::Default - .any_instance.expects(:create).with(@directory_name, @context, getting_started: nil) - .returns(true).once - ExtensionProject.expects(:write_cli_file).with(context: @context, type: @specification_handler.identifier).once - ExtensionProject - .expects(:write_env_file) - .with(context: @context, title: @name, api_key: @app.api_key, api_secret: @app.secret) - .once - - io = capture_io do - run_create(%W(extension --name=#{@name} --type=#{@specification_handler.identifier} - --api-key=#{@app.api_key})) - end - - assert_message_output(io: io, expected_content: [ - @context.message("create.ready_to_start", @directory_name, @name), - @context.message("create.learn_more", @specification_handler.name), - ]) - end - - def test_does_not_create_project_files_and_outputs_try_again_message_if_type_create_failed - ShopifyCLI::Shopifolk.stubs(:check).returns(false) - ShopifyCLI::Feature.stubs(:enabled?).with(:extension_server_beta).returns(false) - - Dir.expects(:exist?).with(@directory_name).returns(false).once - Models::SpecificationHandlers::Default - .any_instance.expects(:create).with(@directory_name, @context, getting_started: nil) - .returns(false).once - ExtensionProject.expects(:write_cli_file).never - ExtensionProject.expects(:write_env_file).never - - io = capture_io do - run_create(%W(extension --name=#{@name} --type=#{@specification_handler.identifier} - --api-key=#{@app.api_key})) - end - - assert_message_output(io: io, expected_content: @context.message("create.try_again")) - end - - private - - def run_create(arguments) - specifications = ExtensionTestHelpers.test_specifications - Models::Specifications.stubs(:new).returns(specifications) - Extension::Command::Create.ctx = @context - Extension::Command::Create.call(arguments, "create", "create") - end - end - end -end