Module: ShopifyCLI

Extended by:
CLI::Kit::Autocall
Defined in:
lib/shopify_cli.rb,
lib/shopify_cli/db.rb,
lib/shopify_cli/api.rb,
lib/shopify_cli/git.rb,
lib/shopify_cli/sed.rb,
lib/shopify_cli/core.rb,
lib/shopify_cli/form.rb,
lib/shopify_cli/task.rb,
lib/shopify_cli/tasks.rb,
lib/shopify_cli/github.rb,
lib/shopify_cli/heroku.rb,
lib/shopify_cli/result.rb,
lib/shopify_cli/tunnel.rb,
lib/shopify_cli/command.rb,
lib/shopify_cli/connect.rb,
lib/shopify_cli/context.rb,
lib/shopify_cli/feature.rb,
lib/shopify_cli/helpers.rb,
lib/shopify_cli/js_deps.rb,
lib/shopify_cli/options.rb,
lib/shopify_cli/project.rb,
lib/shopify_cli/release.rb,
lib/shopify_cli/version.rb,
lib/shopify_cli/commands.rb,
lib/shopify_cli/migrator.rb,
lib/shopify_cli/packager.rb,
lib/shopify_cli/php_deps.rb,
lib/shopify_cli/services.rb,
lib/shopify_cli/admin_api.rb,
lib/shopify_cli/changelog.rb,
lib/shopify_cli/constants.rb,
lib/shopify_cli/js_system.rb,
lib/shopify_cli/resources.rb,
lib/shopify_cli/shopifolk.rb,
lib/shopify_cli/utilities.rb,
lib/shopify_cli/theme/file.rb,
lib/shopify_cli/theme/root.rb,
lib/shopify_cli/environment.rb,
lib/shopify_cli/theme/theme.rb,
lib/shopify_cli/thread_pool.rb,
lib/shopify_cli/commands/app.rb,
lib/shopify_cli/http_request.rb,
lib/shopify_cli/partners_api.rb,
lib/shopify_cli/project_type.rb,
lib/shopify_cli/theme/syncer.rb,
lib/shopify_cli/commands/help.rb,
lib/shopify_cli/core/executor.rb,
lib/shopify_cli/core/finalize.rb,
lib/shopify_cli/core/monorail.rb,
lib/shopify_cli/identity_auth.rb,
lib/shopify_cli/method_object.rb,
lib/shopify_cli/commands/login.rb,
lib/shopify_cli/commands/store.rb,
lib/shopify_cli/lazy_delegator.rb,
lib/shopify_cli/command_options.rb,
lib/shopify_cli/commands/config.rb,
lib/shopify_cli/commands/logout.rb,
lib/shopify_cli/commands/switch.rb,
lib/shopify_cli/commands/system.rb,
lib/shopify_cli/commands/whoami.rb,
lib/shopify_cli/theme/mime_type.rb,
lib/shopify_cli/thread_pool/job.rb,
lib/shopify_cli/admin_api/schema.rb,
lib/shopify_cli/commands/version.rb,
lib/shopify_cli/core/cli_version.rb,
lib/shopify_cli/core/entry_point.rb,
lib/shopify_cli/project_commands.rb,
lib/shopify_cli/resolve_constant.rb,
lib/shopify_cli/tasks/ensure_env.rb,
lib/shopify_cli/theme/dev_server.rb,
lib/shopify_cli/app_type_detector.rb,
lib/shopify_cli/commands/app/open.rb,
lib/shopify_cli/commands/populate.rb,
lib/shopify_cli/messages/messages.rb,
lib/shopify_cli/commands/app/serve.rb,
lib/shopify_cli/commands/reporting.rb,
lib/shopify_cli/core/help_resolver.rb,
lib/shopify_cli/exception_reporter.rb,
lib/shopify_cli/helpers/haikunator.rb,
lib/shopify_cli/migrator/migration.rb,
lib/shopify_cli/resources/env_file.rb,
lib/shopify_cli/command/sub_command.rb,
lib/shopify_cli/commands/app/create.rb,
lib/shopify_cli/commands/app/deploy.rb,
lib/shopify_cli/commands/app/tunnel.rb,
lib/shopify_cli/process_supervision.rb,
lib/shopify_cli/tasks/confirm_store.rb,
lib/shopify_cli/theme/ignore_filter.rb,
lib/shopify_cli/theme/ignore_helper.rb,
lib/shopify_cli/theme/syncer/merger.rb,
lib/shopify_cli/commands/app/connect.rb,
lib/shopify_cli/file_system_listener.rb,
lib/shopify_cli/theme/backoff_helper.rb,
lib/shopify_cli/theme/dev_server/sse.rb,
lib/shopify_cli/theme/include_filter.rb,
lib/shopify_cli/identity_auth/servlet.rb,
lib/shopify_cli/services/base_service.rb,
lib/shopify_cli/theme/syncer/uploader.rb,
lib/shopify_cli/theme/theme_admin_api.rb,
lib/shopify_cli/tasks/ensure_dev_store.rb,
lib/shopify_cli/theme/dev_server/proxy.rb,
lib/shopify_cli/theme/extension/syncer.rb,
lib/shopify_cli/theme/syncer/checksums.rb,
lib/shopify_cli/theme/syncer/operation.rb,
lib/shopify_cli/theme/theme_access_api.rb,
lib/shopify_cli/command/app_sub_command.rb,
lib/shopify_cli/command/project_command.rb,
lib/shopify_cli/commands/app/create/php.rb,
lib/shopify_cli/tasks/create_api_client.rb,
lib/shopify_cli/theme/dev_server/errors.rb,
lib/shopify_cli/theme/development_theme.rb,
lib/shopify_cli/theme/syncer/downloader.rb,
lib/shopify_cli/commands/app/create/node.rb,
lib/shopify_cli/theme/dev_server/watcher.rb,
lib/shopify_cli/transform_data_structure.rb,
lib/shopify_cli/commands/app/create/rails.rb,
lib/shopify_cli/commands/populate/product.rb,
lib/shopify_cli/services/app/open_service.rb,
lib/shopify_cli/tasks/ensure_loopback_url.rb,
lib/shopify_cli/tasks/ensure_project_type.rb,
lib/shopify_cli/tasks/select_org_and_shop.rb,
lib/shopify_cli/theme/filter/path_matcher.rb,
lib/shopify_cli/commands/populate/customer.rb,
lib/shopify_cli/github/issue_url_generator.rb,
lib/shopify_cli/partners_api/organizations.rb,
lib/shopify_cli/services/reporting_service.rb,
lib/shopify_cli/tasks/ensure_authenticated.rb,
lib/shopify_cli/theme/dev_server/cdn_fonts.rb,
lib/shopify_cli/theme/extension/dev_server.rb,
lib/shopify_cli/theme/extension/host_theme.rb,
lib/shopify_cli/theme/syncer/uploader/bulk.rb,
lib/shopify_cli/partners_api/app_extensions.rb,
lib/shopify_cli/tasks/ensure_git_dependency.rb,
lib/shopify_cli/tasks/update_dashboard_urls.rb,
lib/shopify_cli/theme/dev_server/hot_reload.rb,
lib/shopify_cli/theme/dev_server/web_server.rb,
lib/shopify_cli/theme/syncer/error_reporter.rb,
lib/shopify_cli/identity_auth/env_auth_token.rb,
lib/shopify_cli/services/app/connect_service.rb,
lib/shopify_cli/theme/dev_server/header_hash.rb,
lib/shopify_cli/theme/dev_server/reload_mode.rb,
lib/shopify_cli/commands/populate/draft_order.rb,
lib/shopify_cli/theme/dev_server/local_assets.rb,
lib/shopify_cli/theme/extension/app_extension.rb,
lib/shopify_cli/services/app/serve/php_service.rb,
lib/shopify_cli/theme/syncer/standard_reporter.rb,
lib/shopify_cli/theme/syncer/uploader/bulk_job.rb,
lib/shopify_cli/partners_api/app_extensions/job.rb,
lib/shopify_cli/services/app/create/php_service.rb,
lib/shopify_cli/services/app/serve/node_service.rb,
lib/shopify_cli/theme/dev_server/remote_watcher.rb,
lib/shopify_cli/theme/syncer/uploader/bulk_item.rb,
lib/shopify_cli/services/app/create/node_service.rb,
lib/shopify_cli/services/app/serve/rails_service.rb,
lib/shopify_cli/services/app/serve/serve_service.rb,
lib/shopify_cli/services/app/tunnel/auth_service.rb,
lib/shopify_cli/services/app/tunnel/stop_service.rb,
lib/shopify_cli/theme/extension/syncer/operation.rb,
lib/shopify_cli/services/app/create/rails_service.rb,
lib/shopify_cli/services/app/tunnel/start_service.rb,
lib/shopify_cli/reporting_configuration_controller.rb,
lib/shopify_cli/theme/extension/dev_server/watcher.rb,
lib/shopify_cli/theme/syncer/uploader/bulk_request.rb,
lib/shopify_cli/admin_api/populate_resource_command.rb,
lib/shopify_cli/migrator/migrations/1631709766_noop.rb,
lib/shopify_cli/theme/dev_server/certificate_manager.rb,
lib/shopify_cli/theme/dev_server/proxy_param_builder.rb,
lib/shopify_cli/command_options/command_serve_options.rb,
lib/shopify_cli/theme/extension/dev_server/hot_reload.rb,
lib/shopify_cli/services/app/deploy/heroku/php_service.rb,
lib/shopify_cli/services/app/deploy/heroku/node_service.rb,
lib/shopify_cli/theme/dev_server/hooks/file_change_hook.rb,
lib/shopify_cli/theme/extension/dev_server/local_assets.rb,
lib/shopify_cli/theme/syncer/unsupported_script_warning.rb,
lib/shopify_cli/services/app/deploy/heroku/rails_service.rb,
lib/shopify_cli/theme/syncer/uploader/forms/apply_to_all.rb,
lib/shopify_cli/theme/syncer/uploader/json_delete_handler.rb,
lib/shopify_cli/theme/syncer/uploader/json_update_handler.rb,
lib/shopify_cli/theme/dev_server/hot_reload/sections_index.rb,
lib/shopify_cli/theme/extension/syncer/extension_serve_job.rb,
lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb,
lib/shopify_cli/theme/dev_server/hot_reload/script_injector.rb,
lib/shopify_cli/theme/syncer/uploader/forms/apply_to_all_form.rb,
lib/shopify_cli/theme/extension/dev_server/proxy_param_builder.rb,
lib/shopify_cli/theme/syncer/uploader/forms/base_strategy_form.rb,
lib/shopify_cli/theme/dev_server/hot_reload/remote_file_deleter.rb,
lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb,
lib/shopify_cli/theme/extension/dev_server/hooks/file_change_hook.rb,
lib/shopify_cli/theme/syncer/uploader/forms/select_delete_strategy.rb,
lib/shopify_cli/theme/syncer/uploader/forms/select_update_strategy.rb,
lib/shopify_cli/theme/dev_server/remote_watcher/json_files_update_job.rb,
lib/shopify_cli/theme/extension/dev_server/hot_reload/script_injector.rb,
lib/shopify_cli/migrator/migrations/1633691650_merge_reporting_configuration.rb

Overview

‘ResolveConstant` implements constant resolution. It is implemented as a `MethodObject` and therefore returns a result object. By default, constants are resolved relative to `Kernal`, but the top-level namespace is configurable:

ShopifyCLI::Resolve.call(:object).value # => Object
ShopifyCLI::Resolve.call('minitest/test').value # => MiniTest::Test
ShopifyCLI::Resolve.call(:test, namespace: MiniTest) # => MiniTest::Test

Defined Under Namespace

Modules: CommandOptions, Commands, Constants, Core, Environment, ExceptionReporter, GitHub, Helpers, Messages, MethodObject, Migrator, ReportingConfigurationController, Resources, Result, Services, Tasks, Theme, Utilities Classes: API, AdminAPI, AppTypeDetector, Changelog, Command, Connect, Context, DB, Feature, FileSystemListener, Form, Git, Heroku, HttpRequest, IdentityAuth, JsDeps, JsSystem, LazyDelegator, Options, PHPDeps, Packager, PartnersAPI, ProcessSupervision, Project, ProjectCommand, ProjectType, Release, ResolveConstant, Sed, Shopifolk, Task, ThreadPool, TransformDataStructure, Tunnel

Constant Summary collapse

TOOL_NAME =
"shopify"
TOOL_FULL_NAME =
"Shopify CLI"
ROOT =
File.expand_path("../..", __FILE__)
PROJECT_TYPES_DIR =
File.join(ROOT, "lib", "project_types")
TEMP_DIR =
File.join(ROOT, ".tmp")
EMOJI =

programmer emoji if default install location, else wrench emoji

ROOT == "/opt/shopify" ? "\u{1f469}\u{200d}\u{1f4bb}" : "\u{1f527}"
FAILMOJI =

shrug or boom emoji

ROOT == "/opt/shopify" ? "\u{1f937}" : "\u{1f4a5}"
EXIT_FAILURE_BUT_NOT_BUG =

Exit management in ‘shopify-cli` follows the management set out by CLI Kit. github.com/Shopify/cli-kit/blob/main/lib/cli/kit.rb That is to say, we differentiate between exit success (0), exit failure (1), and exit bug (not 1)

These should never be called outside of the entrypoint and its delegations.

CLI::Kit::EXIT_FAILURE_BUT_NOT_BUG
EXIT_BUG =
CLI::Kit::EXIT_BUG
EXIT_SUCCESS =
CLI::Kit::EXIT_SUCCESS
GenericAbort =

‘shopify-cli` uses CLI Kit’s exception management These are documented here: github.com/Shopify/cli-kit/blob/main/lib/cli/kit.rb

You should never subclass these exceptions, but instead rescue another exception and re-raise. AbortSilent and BugSilent should never have messages. They are mostly used when we output explanations and need to exit

CLI::Kit::GenericAbort
Abort =
CLI::Kit::Abort
Bug =
CLI::Kit::Bug
BugSilent =
CLI::Kit::BugSilent
AbortSilent =
CLI::Kit::AbortSilent
VERSION =
"2.36.0"

Class Method Summary collapse

Class Method Details

.cache_dirObject



148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/shopify_cli.rb', line 148

def self.cache_dir
  cache_dir = if Environment.test?
    TEMP_DIR
  elsif ENV["LOCALAPPDATA"].nil?
    File.join(File.expand_path(ENV.fetch("XDG_CACHE_HOME", "~/.cache")), TOOL_NAME)
  else
    File.join(File.expand_path(ENV["LOCALAPPDATA"]), TOOL_NAME)
  end

  # Make sure the cache dir always exists
  @cache_dir_exists ||= FileUtils.mkdir_p(cache_dir)

  cache_dir
end

.debug_log_fileObject



177
178
179
# File 'lib/shopify_cli.rb', line 177

def self.debug_log_file
  File.join(tool_config_path, "logs", "debug.log")
end

.log_fileObject



173
174
175
# File 'lib/shopify_cli.rb', line 173

def self.log_file
  File.join(tool_config_path, "logs", "log.log")
end

.shaObject



181
182
183
184
# File 'lib/shopify_cli.rb', line 181

def self.sha
  return @sha if defined?(@sha)
  @sha = Git.sha(dir: ShopifyCLI::ROOT)
end

.tool_config_pathObject



163
164
165
166
167
168
169
170
171
# File 'lib/shopify_cli.rb', line 163

def self.tool_config_path
  if Environment.test?
    TEMP_DIR
  elsif ENV["APPDATA"].nil?
    File.join(File.expand_path(ENV.fetch("XDG_CONFIG_HOME", "~/.config")), TOOL_NAME)
  else
    File.join(File.expand_path(ENV["APPDATA"]), TOOL_NAME)
  end
end