shopify-cli 2.6.3 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer.json +5 -0
- data/.github/DESIGN.md +1 -1
- data/.github/ISSUE_TEMPLATE.md +7 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +15 -4
- data/.github/workflows/shopify.yml +3 -6
- data/.vscode/extensions.json +5 -0
- data/.vscode/settings.json +9 -0
- data/CHANGELOG.md +98 -104
- data/CONTRIBUTING.md +1 -21
- data/Codespace.dockerfile +35 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +9 -5
- data/README.md +20 -99
- data/RELEASING.md +17 -30
- data/Rakefile +0 -5
- data/Tests.dockerfile +35 -0
- data/assets/logo.png +0 -0
- data/dev.yml +0 -3
- data/docs/README.md +13 -0
- data/docs/contributors/testing.md +27 -0
- data/docs/users/installation.md +46 -0
- data/{THEMEKIT_MIGRATION.md → docs/users/migrate-from-themekit.md} +1 -1
- data/lib/project_types/extension/cli.rb +7 -3
- data/lib/project_types/extension/commands/create.rb +6 -6
- data/lib/project_types/extension/commands/extension_command.rb +1 -1
- data/lib/project_types/extension/features/argo.rb +9 -10
- data/lib/project_types/extension/features/argo_serve.rb +9 -23
- data/lib/project_types/extension/forms/create.rb +1 -1
- data/lib/project_types/extension/forms/questions/ask_template.rb +3 -6
- data/lib/project_types/extension/messages/messages.rb +1 -0
- data/lib/project_types/extension/models/development_server_requirements.rb +2 -3
- data/lib/project_types/extension/models/server_config/app.rb +13 -0
- data/lib/project_types/extension/models/server_config/development.rb +5 -4
- data/lib/project_types/extension/models/server_config/development_renderer.rb +1 -1
- data/lib/project_types/extension/models/server_config/development_resource.rb +13 -0
- data/lib/project_types/extension/models/server_config/extension.rb +4 -0
- data/lib/project_types/extension/models/server_config/root.rb +4 -1
- data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +1 -1
- data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +1 -1
- data/lib/project_types/extension/tasks/convert_server_config.rb +65 -0
- data/lib/project_types/extension/tasks/ensure_resource_url.rb +39 -0
- data/lib/project_types/extension/tasks/find_package_from_json.rb +37 -0
- data/lib/project_types/extension/tasks/merge_server_config.rb +32 -0
- data/lib/project_types/extension/tasks/run_extension_command.rb +10 -9
- data/lib/project_types/node/cli.rb +0 -16
- data/lib/project_types/node/forms/create.rb +5 -5
- data/lib/project_types/node/messages/messages.rb +2 -149
- data/lib/project_types/php/cli.rb +0 -11
- data/lib/project_types/php/forms/create.rb +5 -6
- data/lib/project_types/php/messages/messages.rb +2 -164
- data/lib/project_types/rails/cli.rb +0 -16
- data/lib/project_types/rails/commands/create.rb +46 -17
- data/lib/project_types/rails/forms/create.rb +5 -7
- data/lib/project_types/rails/messages/messages.rb +6 -154
- data/lib/project_types/script/cli.rb +1 -1
- data/lib/project_types/script/commands/create.rb +5 -6
- data/lib/project_types/script/commands/push.rb +1 -1
- data/lib/project_types/script/config/extension_points.yml +10 -0
- data/lib/project_types/script/errors.rb +0 -18
- data/lib/project_types/script/graphql/app_script_set.graphql +2 -0
- data/lib/project_types/script/layers/application/build_script.rb +2 -1
- data/lib/project_types/script/layers/application/create_script.rb +2 -2
- data/lib/project_types/script/layers/application/push_script.rb +15 -1
- data/lib/project_types/script/layers/domain/push_package.rb +5 -2
- data/lib/project_types/script/layers/domain/script_json.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -4
- data/lib/project_types/script/layers/infrastructure/errors.rb +17 -2
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +29 -13
- data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +29 -13
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +4 -2
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +3 -4
- data/lib/project_types/script/layers/infrastructure/script_service.rb +7 -2
- data/lib/project_types/script/messages/messages.rb +9 -22
- data/lib/project_types/script/ui/error_handler.rb +16 -26
- data/lib/project_types/theme/cli.rb +1 -1
- data/lib/project_types/theme/commands/check.rb +1 -1
- data/lib/project_types/theme/commands/delete.rb +1 -1
- data/lib/project_types/theme/commands/init.rb +1 -1
- data/lib/project_types/theme/commands/language_server.rb +1 -1
- data/lib/project_types/theme/commands/package.rb +1 -1
- data/lib/project_types/theme/commands/publish.rb +1 -1
- data/lib/project_types/theme/commands/pull.rb +1 -1
- data/lib/project_types/theme/commands/push.rb +1 -1
- data/lib/project_types/theme/commands/serve.rb +10 -2
- data/lib/project_types/theme/messages/messages.rb +10 -0
- data/lib/shopify_cli/admin_api/populate_resource_command.rb +1 -1
- data/lib/shopify_cli/api.rb +7 -2
- data/lib/shopify_cli/app_type_detector.rb +36 -0
- data/lib/shopify_cli/command/app_sub_command.rb +10 -0
- data/lib/shopify_cli/command/project_command.rb +18 -0
- data/lib/shopify_cli/command/sub_command.rb +19 -0
- data/lib/shopify_cli/command.rb +13 -3
- data/lib/shopify_cli/command_options/command_serve_options.rb +43 -0
- data/lib/shopify_cli/command_options.rb +7 -0
- data/lib/shopify_cli/commands/app/connect.rb +22 -0
- data/lib/shopify_cli/commands/app/create/node.rb +38 -0
- data/lib/shopify_cli/commands/app/create/php.rb +36 -0
- data/lib/shopify_cli/commands/app/create/rails.rb +40 -0
- data/lib/shopify_cli/commands/app/create.rb +28 -0
- data/lib/shopify_cli/commands/app/deploy.rb +49 -0
- data/lib/shopify_cli/commands/app/open.rb +19 -0
- data/lib/shopify_cli/commands/app/serve.rb +49 -0
- data/lib/shopify_cli/commands/app/tunnel.rb +43 -0
- data/lib/shopify_cli/commands/app.rb +29 -0
- data/lib/shopify_cli/commands/config.rb +2 -2
- data/lib/shopify_cli/commands/login.rb +3 -3
- data/lib/shopify_cli/commands/reporting.rb +38 -0
- data/lib/shopify_cli/commands/switch.rb +1 -1
- data/lib/shopify_cli/commands.rb +2 -0
- data/lib/shopify_cli/constants.rb +11 -3
- data/lib/shopify_cli/core/monorail.rb +9 -20
- data/lib/shopify_cli/environment.rb +15 -1
- data/lib/shopify_cli/exception_reporter.rb +29 -16
- data/lib/shopify_cli/git.rb +12 -1
- data/lib/shopify_cli/github/issue_url_generator.rb +19 -0
- data/lib/shopify_cli/github.rb +5 -0
- data/lib/shopify_cli/messages/messages.rb +295 -22
- data/lib/shopify_cli/migrator/migration.rb +1 -1
- data/lib/shopify_cli/migrator/migrations/1631709766_noop.rb +1 -1
- data/lib/shopify_cli/migrator/migrations/1633691650_merge_reporting_configuration.rb +41 -0
- data/lib/shopify_cli/migrator.rb +9 -11
- data/lib/shopify_cli/project.rb +5 -1
- data/lib/shopify_cli/project_commands.rb +1 -1
- data/lib/shopify_cli/reporting_configuration_controller.rb +64 -0
- data/lib/shopify_cli/services/app/connect_service.rb +25 -0
- data/lib/shopify_cli/services/app/create/node_service.rb +153 -0
- data/lib/shopify_cli/services/app/create/php_service.rb +152 -0
- data/lib/shopify_cli/services/app/create/rails_service.rb +213 -0
- data/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +101 -0
- data/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +135 -0
- data/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +120 -0
- data/lib/shopify_cli/services/app/open_service.rb +19 -0
- data/lib/shopify_cli/services/app/serve/node_service.rb +42 -0
- data/lib/shopify_cli/services/app/serve/php_service.rb +46 -0
- data/lib/shopify_cli/services/app/serve/rails_service.rb +48 -0
- data/lib/shopify_cli/services/app/tunnel/auth_service.rb +21 -0
- data/lib/shopify_cli/services/app/tunnel/start_service.rb +20 -0
- data/lib/shopify_cli/services/app/tunnel/stop_service.rb +20 -0
- data/lib/shopify_cli/services/base_service.rb +13 -0
- data/lib/shopify_cli/services/reporting_service.rb +16 -0
- data/lib/shopify_cli/services.rb +37 -0
- data/lib/shopify_cli/theme/dev_server/local_assets.rb +1 -1
- data/lib/shopify_cli/theme/dev_server/watcher.rb +2 -2
- data/lib/shopify_cli/theme/dev_server.rb +9 -2
- data/lib/shopify_cli/version.rb +1 -1
- data/lib/shopify_cli.rb +5 -2
- data/shopify-cli.gemspec +2 -13
- data/shopify-dev +18 -0
- data/utilities/constants.rb +7 -0
- data/utilities/docker/container.rb +104 -0
- data/utilities/docker.rb +45 -3
- data/utilities/utilities.rb +1 -0
- metadata +63 -54
- data/Dockerfile +0 -17
- data/docs/_config.yml +0 -2
- data/docs/app/node/commands/index.md +0 -4
- data/docs/app/node/index.md +0 -4
- data/docs/app/rails/commands/index.md +0 -4
- data/docs/app/rails/index.md +0 -4
- data/docs/core/index.md +0 -4
- data/docs/getting-started/index.md +0 -4
- data/docs/getting-started/install/index.md +0 -4
- data/docs/getting-started/migrate/index.md +0 -4
- data/docs/getting-started/uninstall/index.md +0 -4
- data/docs/getting-started/upgrade/index.md +0 -4
- data/docs/help/start-app/index.md +0 -4
- data/docs/index.md +0 -4
- data/ext/shopify-cli/extconf.rb +0 -60
- data/install.sh +0 -7
- data/lib/project_types/extension/tasks/converters/server_config_converter.rb +0 -31
- data/lib/project_types/extension/tasks/load_server_config.rb +0 -23
- data/lib/project_types/node/commands/connect.rb +0 -21
- data/lib/project_types/node/commands/create.rb +0 -125
- data/lib/project_types/node/commands/deploy/heroku.rb +0 -96
- data/lib/project_types/node/commands/deploy.rb +0 -32
- data/lib/project_types/node/commands/generate.rb +0 -22
- data/lib/project_types/node/commands/open.rb +0 -18
- data/lib/project_types/node/commands/serve.rb +0 -54
- data/lib/project_types/node/commands/tunnel.rb +0 -41
- data/lib/project_types/php/commands/connect.rb +0 -19
- data/lib/project_types/php/commands/create.rb +0 -143
- data/lib/project_types/php/commands/deploy/heroku.rb +0 -129
- data/lib/project_types/php/commands/deploy.rb +0 -32
- data/lib/project_types/php/commands/open.rb +0 -16
- data/lib/project_types/php/commands/serve.rb +0 -51
- data/lib/project_types/php/commands/tunnel.rb +0 -37
- data/lib/project_types/rails/commands/connect.rb +0 -21
- data/lib/project_types/rails/commands/deploy/heroku.rb +0 -115
- data/lib/project_types/rails/commands/deploy.rb +0 -32
- data/lib/project_types/rails/commands/generate/webhook.rb +0 -42
- data/lib/project_types/rails/commands/generate.rb +0 -60
- data/lib/project_types/rails/commands/open.rb +0 -18
- data/lib/project_types/rails/commands/serve.rb +0 -52
- data/lib/project_types/rails/commands/tunnel.rb +0 -41
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -0
- data/lib/shopify_cli/exception_reporter/permission_controller.rb +0 -54
- data/lib/shopify_cli/sub_command.rb +0 -17
- data/shopify.fish +0 -12
- data/shopify.sh +0 -11
@@ -0,0 +1,48 @@
|
|
1
|
+
module ShopifyCLI
|
2
|
+
module Services
|
3
|
+
module App
|
4
|
+
module Serve
|
5
|
+
class RailsService < BaseService
|
6
|
+
attr_accessor :host, :port, :context
|
7
|
+
|
8
|
+
def initialize(host:, port:, context:)
|
9
|
+
@host = host
|
10
|
+
@port = port
|
11
|
+
@context = context
|
12
|
+
super()
|
13
|
+
end
|
14
|
+
|
15
|
+
def call
|
16
|
+
project = ShopifyCLI::Project.current
|
17
|
+
url = host || ShopifyCLI::Tunnel.start(context)
|
18
|
+
raise ShopifyCLI::Abort,
|
19
|
+
context.message("core.app.serve.error.host_must_be_https") if url.match(/^https/i).nil?
|
20
|
+
project.env.update(context, :host, url)
|
21
|
+
ShopifyCLI::Tasks::UpdateDashboardURLS.call(
|
22
|
+
context,
|
23
|
+
url: url,
|
24
|
+
callback_url: "/auth/shopify/callback",
|
25
|
+
)
|
26
|
+
|
27
|
+
if project.env.shop
|
28
|
+
project_url = "#{project.env.host}/login?shop=#{project.env.shop}"
|
29
|
+
context.puts("\n" + context.message("core.app.serve.open_info", project_url) + "\n")
|
30
|
+
end
|
31
|
+
|
32
|
+
CLI::UI::Frame.open(context.message("core.app.serve.running_server")) do
|
33
|
+
env = ShopifyCLI::Project.current.env.to_h
|
34
|
+
env.delete("HOST")
|
35
|
+
env["PORT"] = port.to_s
|
36
|
+
env["GEM_PATH"] = Rails::Gem.gem_path(context)
|
37
|
+
if context.windows?
|
38
|
+
context.system("ruby bin\\rails server", env: env)
|
39
|
+
else
|
40
|
+
context.system("bin/rails server", env: env)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ShopifyCLI
|
2
|
+
module Services
|
3
|
+
module App
|
4
|
+
module Tunnel
|
5
|
+
class AuthService < BaseService
|
6
|
+
attr_accessor :context, :token
|
7
|
+
|
8
|
+
def initialize(token:, context:)
|
9
|
+
@context = context
|
10
|
+
@token = token
|
11
|
+
super()
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
ShopifyCLI::Tunnel.auth(context, token)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ShopifyCLI
|
2
|
+
module Services
|
3
|
+
module App
|
4
|
+
module Tunnel
|
5
|
+
class StartService < BaseService
|
6
|
+
attr_accessor :context
|
7
|
+
|
8
|
+
def initialize(context:)
|
9
|
+
@context = context
|
10
|
+
super()
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
ShopifyCLI::Tunnel.start(context)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ShopifyCLI
|
2
|
+
module Services
|
3
|
+
module App
|
4
|
+
module Tunnel
|
5
|
+
class StopService < BaseService
|
6
|
+
attr_accessor :context
|
7
|
+
|
8
|
+
def initialize(context:)
|
9
|
+
@context = context
|
10
|
+
super()
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
ShopifyCLI::Tunnel.stop(context)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ShopifyCLI
|
2
|
+
module Services
|
3
|
+
class ReportingService < BaseService
|
4
|
+
attr_reader :enable
|
5
|
+
|
6
|
+
def initialize(enable:)
|
7
|
+
@enable = enable
|
8
|
+
super()
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
ReportingConfigurationController.enable_reporting(enable)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ShopifyCLI
|
2
|
+
module Services
|
3
|
+
autoload :BaseService, "shopify_cli/services/base_service"
|
4
|
+
autoload :ReportingService, "shopify_cli/services/reporting_service"
|
5
|
+
|
6
|
+
module App
|
7
|
+
module Serve
|
8
|
+
autoload :NodeService, "shopify_cli/services/app/serve/node_service"
|
9
|
+
autoload :RailsService, "shopify_cli/services/app/serve/rails_service"
|
10
|
+
autoload :PHPService, "shopify_cli/services/app/serve/php_service"
|
11
|
+
end
|
12
|
+
|
13
|
+
module Create
|
14
|
+
autoload :NodeService, "shopify_cli/services/app/create/node_service"
|
15
|
+
autoload :RailsService, "shopify_cli/services/app/create/rails_service"
|
16
|
+
autoload :PHPService, "shopify_cli/services/app/create/php_service"
|
17
|
+
end
|
18
|
+
|
19
|
+
module Deploy
|
20
|
+
module Heroku
|
21
|
+
autoload :NodeService, "shopify_cli/services/app/deploy/heroku/node_service"
|
22
|
+
autoload :RailsService, "shopify_cli/services/app/deploy/heroku/rails_service"
|
23
|
+
autoload :PHPService, "shopify_cli/services/app/deploy/heroku/php_service"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module Tunnel
|
28
|
+
autoload :StartService, "shopify_cli/services/app/tunnel/start_service"
|
29
|
+
autoload :StopService, "shopify_cli/services/app/tunnel/stop_service"
|
30
|
+
autoload :AuthService, "shopify_cli/services/app/tunnel/auth_service"
|
31
|
+
end
|
32
|
+
|
33
|
+
autoload :ConnectService, "shopify_cli/services/app/connect_service"
|
34
|
+
autoload :OpenService, "shopify_cli/services/app/open_service"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -9,12 +9,12 @@ module ShopifyCLI
|
|
9
9
|
class Watcher
|
10
10
|
include Observable
|
11
11
|
|
12
|
-
def initialize(ctx, theme:, syncer:, ignore_filter: nil)
|
12
|
+
def initialize(ctx, theme:, syncer:, ignore_filter: nil, poll: false)
|
13
13
|
@ctx = ctx
|
14
14
|
@theme = theme
|
15
15
|
@syncer = syncer
|
16
16
|
@ignore_filter = ignore_filter
|
17
|
-
@listener = Listen.to(@theme.root) do |modified, added, removed|
|
17
|
+
@listener = Listen.to(@theme.root, force_polling: poll) do |modified, added, removed|
|
18
18
|
changed
|
19
19
|
notify_observers(modified, added, removed)
|
20
20
|
end
|
@@ -17,15 +17,19 @@ require "pathname"
|
|
17
17
|
module ShopifyCLI
|
18
18
|
module Theme
|
19
19
|
module DevServer
|
20
|
+
# Errors
|
21
|
+
Error = Class.new(StandardError)
|
22
|
+
AddressBindingError = Class.new(Error)
|
23
|
+
|
20
24
|
class << self
|
21
25
|
attr_accessor :ctx
|
22
26
|
|
23
|
-
def start(ctx, root, port: 9292)
|
27
|
+
def start(ctx, root, http_bind: "127.0.0.1", port: 9292, poll: false)
|
24
28
|
@ctx = ctx
|
25
29
|
theme = DevelopmentTheme.new(ctx, root: root)
|
26
30
|
ignore_filter = IgnoreFilter.from_path(root)
|
27
31
|
@syncer = Syncer.new(ctx, theme: theme, ignore_filter: ignore_filter)
|
28
|
-
watcher = Watcher.new(ctx, theme: theme, syncer: @syncer, ignore_filter: ignore_filter)
|
32
|
+
watcher = Watcher.new(ctx, theme: theme, syncer: @syncer, ignore_filter: ignore_filter, poll: poll)
|
29
33
|
|
30
34
|
# Setup the middleware stack. Mimics Rack::Builder / config.ru, but in reverse order
|
31
35
|
@app = Proxy.new(ctx, theme: theme, syncer: @syncer)
|
@@ -74,6 +78,7 @@ module ShopifyCLI
|
|
74
78
|
watcher.start
|
75
79
|
WebServer.run(
|
76
80
|
@app,
|
81
|
+
BindAddress: http_bind,
|
77
82
|
Port: port,
|
78
83
|
Logger: logger,
|
79
84
|
AccessLog: [],
|
@@ -84,6 +89,8 @@ module ShopifyCLI
|
|
84
89
|
ShopifyCLI::API::APIRequestUnauthorizedError
|
85
90
|
@ctx.abort("You are not authorized to edit themes on #{theme.shop}.\n" \
|
86
91
|
"Make sure you are a user of that store, and allowed to edit themes.")
|
92
|
+
rescue Errno::EADDRNOTAVAIL
|
93
|
+
raise AddressBindingError, "Error binding to the address #{http_bind}."
|
87
94
|
end
|
88
95
|
|
89
96
|
def stop
|
data/lib/shopify_cli/version.rb
CHANGED
data/lib/shopify_cli.rb
CHANGED
@@ -96,11 +96,13 @@ module ShopifyCLI
|
|
96
96
|
)
|
97
97
|
end
|
98
98
|
|
99
|
+
autoload :AppTypeDetector, "shopify_cli/app_type_detector"
|
99
100
|
autoload :Constants, "shopify_cli/constants"
|
100
101
|
autoload :Environment, "shopify_cli/environment"
|
101
102
|
autoload :AdminAPI, "shopify_cli/admin_api"
|
102
103
|
autoload :API, "shopify_cli/api"
|
103
104
|
autoload :Command, "shopify_cli/command"
|
105
|
+
autoload :CommandOptions, "shopify_cli/command_options"
|
104
106
|
autoload :Commands, "shopify_cli/commands"
|
105
107
|
autoload :Connect, "shopify_cli/connect"
|
106
108
|
autoload :Context, "shopify_cli/context"
|
@@ -109,6 +111,7 @@ module ShopifyCLI
|
|
109
111
|
autoload :Feature, "shopify_cli/feature"
|
110
112
|
autoload :Form, "shopify_cli/form"
|
111
113
|
autoload :Git, "shopify_cli/git"
|
114
|
+
autoload :GitHub, "shopify_cli/github"
|
112
115
|
autoload :Helpers, "shopify_cli/helpers"
|
113
116
|
autoload :Heroku, "shopify_cli/heroku"
|
114
117
|
autoload :IdentityAuth, "shopify_cli/identity_auth"
|
@@ -121,13 +124,13 @@ module ShopifyCLI
|
|
121
124
|
autoload :PartnersAPI, "shopify_cli/partners_api"
|
122
125
|
autoload :ProcessSupervision, "shopify_cli/process_supervision"
|
123
126
|
autoload :Project, "shopify_cli/project"
|
124
|
-
autoload :ProjectCommands, "shopify_cli/project_commands"
|
125
127
|
autoload :ProjectType, "shopify_cli/project_type"
|
128
|
+
autoload :ReportingConfigurationController, "shopify_cli/reporting_configuration_controller"
|
126
129
|
autoload :ResolveConstant, "shopify_cli/resolve_constant"
|
127
130
|
autoload :Resources, "shopify_cli/resources"
|
128
131
|
autoload :Result, "shopify_cli/result"
|
132
|
+
autoload :Services, "shopify_cli/services"
|
129
133
|
autoload :Shopifolk, "shopify_cli/shopifolk"
|
130
|
-
autoload :SubCommand, "shopify_cli/sub_command"
|
131
134
|
autoload :Task, "shopify_cli/task"
|
132
135
|
autoload :Tasks, "shopify_cli/tasks"
|
133
136
|
autoload :TransformDataStructure, "shopify_cli/transform_data_structure"
|
data/shopify-cli.gemspec
CHANGED
@@ -33,11 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
end
|
34
34
|
spec.bindir = "bin"
|
35
35
|
spec.require_paths = ["lib", "vendor"]
|
36
|
-
spec.
|
37
|
-
# Do NOT include `shopify` as a listed executable via `spec.executables`.
|
38
|
-
# `ext/shopify-cli/extconf.rb` will dynamically create a script and soft-link
|
39
|
-
# `/usr/local/bin/shopify` to that script, in order to "lock" the Ruby used to
|
40
|
-
# a single Ruby (useful for debugging in multi-Ruby environments)
|
36
|
+
spec.executables << "shopify"
|
41
37
|
|
42
38
|
spec.add_development_dependency("bundler", "~> 2.2.2")
|
43
39
|
spec.add_development_dependency("rake", "~> 12.3", ">= 12.3.3")
|
@@ -45,12 +41,5 @@ Gem::Specification.new do |spec|
|
|
45
41
|
|
46
42
|
spec.add_dependency("bugsnag", "~> 6.22")
|
47
43
|
spec.add_dependency("listen", "~> 3.7.0")
|
48
|
-
|
49
|
-
# Note: theme-check is _intentionally_ not specifying the third
|
50
|
-
# digit. We _want_ new features to make their way into new installs
|
51
|
-
# of the Shopify CLI. Otherwise updates need to be released twice.
|
52
|
-
#
|
53
|
-
# That is, DO USE ~> 1.X, DO NOT USE ~> 1.X.Y, this would unnecessarily
|
54
|
-
# fix the feature version.
|
55
|
-
spec.add_dependency("theme-check", "~> 1.7")
|
44
|
+
spec.add_dependency("theme-check", "~> 1.8.0")
|
56
45
|
end
|
data/shopify-dev
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative "./bin/load_shopify"
|
4
|
+
|
5
|
+
exit(proc do
|
6
|
+
begin
|
7
|
+
ShopifyCLI::ErrorHandler.call do
|
8
|
+
ShopifyCLI::Core::EntryPoint.call(ARGV.dup)
|
9
|
+
end
|
10
|
+
rescue StandardError => error
|
11
|
+
ShopifyCLI::ErrorHandler.exception = error
|
12
|
+
if ShopifyCLI::Environment.print_stacktrace?
|
13
|
+
raise error
|
14
|
+
else
|
15
|
+
1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end.call)
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require "open3"
|
2
|
+
require "colorize"
|
3
|
+
|
4
|
+
module Utilities
|
5
|
+
module Docker
|
6
|
+
class Container
|
7
|
+
SHOPIFY_PATH = "/usr/src/app"
|
8
|
+
SHOPIFY_BIN_PATH = "/usr/src/app/bin/shopify"
|
9
|
+
|
10
|
+
Error = Class.new(StandardError)
|
11
|
+
|
12
|
+
attr_reader :id, :env, :cwd, :xdg_config_home, :xdg_cache_home
|
13
|
+
|
14
|
+
def initialize(id:, env:, cwd:)
|
15
|
+
@id = id
|
16
|
+
@cwd = cwd
|
17
|
+
@xdg_config_home = File.join(cwd, ".config")
|
18
|
+
@xdg_cache_home = File.join(cwd, ".cache")
|
19
|
+
@env = env.merge({
|
20
|
+
"XDG_CONFIG_HOME" => @xdg_config_home,
|
21
|
+
"XDG_CACHE_HOME" => @xdg_cache_home,
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
25
|
+
def remove
|
26
|
+
_, stderr, stat = Open3.capture3(
|
27
|
+
"docker", "rm", "-f", @id
|
28
|
+
)
|
29
|
+
raise Error, stderr unless stat.success?
|
30
|
+
end
|
31
|
+
|
32
|
+
def capture_shopify(*args)
|
33
|
+
capture(*([SHOPIFY_BIN_PATH] + args))
|
34
|
+
end
|
35
|
+
|
36
|
+
def capture(*args, relative_dir: nil)
|
37
|
+
command = ["docker", "exec"]
|
38
|
+
cwd = if relative_dir.nil?
|
39
|
+
@cwd
|
40
|
+
else
|
41
|
+
File.join(@cwd, relative_dir)
|
42
|
+
end
|
43
|
+
command += ["-w", cwd]
|
44
|
+
@env.each do |env_name, env_value|
|
45
|
+
command += ["--env", "#{env_name}=#{env_value}"]
|
46
|
+
end
|
47
|
+
command << @id
|
48
|
+
command += args
|
49
|
+
|
50
|
+
out, err, stat = Open3.capture3(*command)
|
51
|
+
raise Error, err unless stat.success?
|
52
|
+
out
|
53
|
+
end
|
54
|
+
|
55
|
+
def exec_shopify(*args, relative_dir: nil)
|
56
|
+
exec(*([SHOPIFY_BIN_PATH] + args), relative_dir: relative_dir)
|
57
|
+
end
|
58
|
+
|
59
|
+
def exec(*args, relative_dir: nil)
|
60
|
+
if ARGV.include?("--verbose")
|
61
|
+
running_prefix = "Running command: #{args.join(" ")}"
|
62
|
+
STDOUT.puts(running_prefix.colorize(:yellow).bold)
|
63
|
+
end
|
64
|
+
command = ["docker", "exec"]
|
65
|
+
cwd = if relative_dir.nil?
|
66
|
+
@cwd
|
67
|
+
else
|
68
|
+
File.join(@cwd, relative_dir)
|
69
|
+
end
|
70
|
+
command += ["-w", cwd]
|
71
|
+
@env.each do |env_name, env_value|
|
72
|
+
command += ["--env", "#{env_name}=#{env_value}"]
|
73
|
+
end
|
74
|
+
command << @id
|
75
|
+
command += args
|
76
|
+
|
77
|
+
docker_prefix = "Docker (#{args.first}):"
|
78
|
+
|
79
|
+
if ARGV.include?("--verbose")
|
80
|
+
stat = Open3.popen3(*command) do |stdin, stdout, stderr, wait_thread|
|
81
|
+
Thread.new do
|
82
|
+
stdout.each { |l| STDOUT.puts("#{docker_prefix.colorize(:cyan).bold} #{l}") } unless stdout&.nil?
|
83
|
+
end
|
84
|
+
Thread.new do
|
85
|
+
stderr.each { |l| STDERR.puts("#{docker_prefix.colorize(:red).bold} #{l}") } unless stderr&.nil?
|
86
|
+
end
|
87
|
+
stdin.close
|
88
|
+
|
89
|
+
status = wait_thread.value
|
90
|
+
|
91
|
+
stdout.close
|
92
|
+
stderr.close
|
93
|
+
|
94
|
+
status
|
95
|
+
end
|
96
|
+
raise StandardError, "The command #{args.first} failed" unless stat.success?
|
97
|
+
else
|
98
|
+
out, stat = Open3.capture2e(*command)
|
99
|
+
raise Error, out unless stat.success?
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
data/utilities/docker.rb
CHANGED
@@ -1,10 +1,43 @@
|
|
1
1
|
require "open3"
|
2
|
+
require "securerandom"
|
2
3
|
|
3
4
|
module Utilities
|
4
5
|
module Docker
|
6
|
+
autoload :Container, "docker/container"
|
7
|
+
|
5
8
|
Error = Class.new(StandardError)
|
6
9
|
|
7
10
|
class << self
|
11
|
+
def create_container(env: {})
|
12
|
+
id = SecureRandom.hex
|
13
|
+
cwd = "/tmp/#{SecureRandom.hex}"
|
14
|
+
|
15
|
+
build_image_if_needed
|
16
|
+
|
17
|
+
_, stderr, stat = Open3.capture3(
|
18
|
+
"docker", "run",
|
19
|
+
"-t", "-d",
|
20
|
+
"--name", id,
|
21
|
+
"--volume", "#{Shellwords.escape(root_dir)}:/usr/src/app",
|
22
|
+
image_tag,
|
23
|
+
"tail", "-f", "/dev/null"
|
24
|
+
)
|
25
|
+
raise Error, stderr unless stat.success?
|
26
|
+
|
27
|
+
_, stderr, stat = Open3.capture3(
|
28
|
+
"docker", "exec",
|
29
|
+
id,
|
30
|
+
"mkdir", "-p", cwd
|
31
|
+
)
|
32
|
+
raise Error, stderr unless stat.success?
|
33
|
+
|
34
|
+
Container.new(
|
35
|
+
id: id,
|
36
|
+
cwd: cwd,
|
37
|
+
env: env
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
8
41
|
def run_and_rm_container(*args)
|
9
42
|
build_image_if_needed
|
10
43
|
system(
|
@@ -24,18 +57,27 @@ module Utilities
|
|
24
57
|
|
25
58
|
def build_image_if_needed
|
26
59
|
unless image_exists?(image_tag)
|
27
|
-
|
60
|
+
puts "Rebuilding the Docker image..."
|
61
|
+
_, err, stat = Open3.capture3(
|
62
|
+
"docker", "build", "-t", image_tag, "-f", File.join(root_dir, "Tests.dockerfile"), root_dir
|
63
|
+
)
|
64
|
+
raise Error, err unless stat.success?
|
28
65
|
end
|
29
66
|
end
|
30
67
|
|
31
68
|
def image_tag
|
32
69
|
gemfile_lock_path = File.expand_path("./Gemfile.lock", root_dir)
|
33
|
-
|
70
|
+
dockerfile_path = File.expand_path("./Tests.dockerfile", root_dir)
|
71
|
+
fingerprintable_strings = [
|
72
|
+
File.read(gemfile_lock_path),
|
73
|
+
File.read(dockerfile_path),
|
74
|
+
]
|
75
|
+
image_sha = Digest::SHA256.hexdigest(fingerprintable_strings.join("-"))
|
34
76
|
"shopify-cli-#{image_sha}"
|
35
77
|
end
|
36
78
|
|
37
79
|
def image_exists?(tag)
|
38
|
-
_, stat = Open3.
|
80
|
+
_, stat = Open3.capture2e(
|
39
81
|
"docker", "inspect",
|
40
82
|
"--type=image",
|
41
83
|
tag
|