Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Port changes from CLI 3 to 2 (#2735)
Browse files Browse the repository at this point in the history
### WHY are these changes introduced?
Backports changes from CLI 3 to CLI 2, until CLI 2 is sunset.

### WHAT is this pull request doing?

Back-port from
* Shopify/cli#1369
* Shopify/cli#1410
  • Loading branch information
Julien Poitrin authored Mar 3, 2023
1 parent 346323f commit b5d3d2a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h

## [Unreleased]

### Fixed
* [#2735](https://github.com/Shopify/shopify-cli/pull/2735): Remove theme directory confirmation during tests and make confirmation dialogue respect `SHOPIFY_CLI_TTY` (from cli#1369)

### Added
* [#2735](https://github.com/Shopify/shopify-cli/pull/2735): Pass development theme from CLI 3’s to CLI 2’s local storage (from cli#1410)

## Version 2.35.0 - 2023-02-22

### Fixed
Expand Down
5 changes: 3 additions & 2 deletions lib/project_types/theme/commands/common/root_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ def exist_and_not_empty?(root)
private

def current_directory_confirmed?
raise "Current theme directory can't be confirmed during tests" if @ctx.testing?
return true if options.flags[:force]

@ctx.warn(@ctx.message("theme.current_directory_is_not_theme_directory"))
Forms::ConfirmStore.ask(
@ctx,
[],
title: @ctx.message("theme.confirm_current_directory"),
force: options.flags[:force],
force: !ShopifyCLI::Environment.interactive?,
).confirmed?
end

Expand Down
6 changes: 6 additions & 0 deletions lib/project_types/theme/commands/pull.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ class Pull < ShopifyCLI::Command::SubCommand
flags[:ignores] |= pattern
end
parser.on("-f", "--force") { flags[:force] = true }
parser.on("--development-theme-id=DEVELOPMENT_THEME_ID") do |development_theme_id|
flags[:development_theme_id] = development_theme_id.to_i
end
end

def call(_args, name)
root = root_value(options, name)
return if exist_and_not_empty?(root) && !valid_theme_directory?(root)

development_theme_id = options.flags[:development_theme_id]
ShopifyCLI::DB.set(development_theme_id: development_theme_id) unless development_theme_id.nil?

delete = !options.flags[:nodelete]
theme = find_theme(root, **options.flags)
return if theme.nil?
Expand Down
6 changes: 6 additions & 0 deletions lib/project_types/theme/commands/push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ class Push < ShopifyCLI::Command::SubCommand
flags[:ignores] |= pattern
end
parser.on("-f", "--force") { flags[:force] = true }
parser.on("--development-theme-id=DEVELOPMENT_THEME_ID") do |development_theme_id|
flags[:development_theme_id] = development_theme_id.to_i
end
end

def call(_args, name)
root = root_value(options, name)
return unless valid_theme_directory?(root)

development_theme_id = options.flags[:development_theme_id]
ShopifyCLI::DB.set(development_theme_id: development_theme_id) unless development_theme_id.nil?

delete = !options.flags[:nodelete]
theme = find_theme(root, **options.flags)
return if theme.nil?
Expand Down
6 changes: 4 additions & 2 deletions lib/project_types/theme/messages/messages.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Theme
module Messages
MESSAGES = {
Expand All @@ -18,8 +19,9 @@ module Messages
ENSURE_USER
stable_flag_suggestion: "If the current command isn't working as expected," \
" we suggest re-running the command with the {{command: --stable}} flag",
confirm_current_directory: "It doesn’t seem like you’re running this command in a theme directory. " \
"Are you sure you want to proceed?",
current_directory_is_not_theme_directory: "It doesn’t seem like you’re running this command" \
" in a theme directory.",
confirm_current_directory: "Are you sure you want to proceed?",
init: {
help: <<~HELP,
{{command:%s theme init}}: Clones a Git repository to use as a starting point for building a new theme.
Expand Down

0 comments on commit b5d3d2a

Please sign in to comment.