shopify-cli 1.9.1 → 1.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +1 -0
- data/.github/workflows/build.yml +28 -0
- data/.github/workflows/release.yml +2 -4
- data/CHANGELOG.md +28 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/project_types/extension/cli.rb +6 -2
- data/lib/project_types/extension/commands/serve.rb +69 -1
- data/lib/project_types/extension/commands/tunnel.rb +3 -1
- data/lib/project_types/extension/extension_project.rb +1 -0
- data/lib/project_types/extension/features/argo.rb +15 -24
- data/lib/project_types/extension/features/argo_runtime.rb +91 -0
- data/lib/project_types/extension/features/argo_serve.rb +35 -27
- data/lib/project_types/extension/features/argo_serve_options.rb +42 -0
- data/lib/project_types/extension/messages/messages.rb +5 -1
- data/lib/project_types/extension/models/npm_package.rb +14 -0
- data/lib/project_types/extension/models/specification.rb +1 -0
- data/lib/project_types/extension/models/specification_handlers/checkout_argo_extension.rb +18 -0
- data/lib/project_types/extension/models/specification_handlers/default.rb +33 -3
- data/lib/project_types/extension/tasks/choose_next_available_port.rb +36 -0
- data/lib/project_types/extension/tasks/configure_features.rb +2 -0
- data/lib/project_types/extension/tasks/find_npm_packages.rb +106 -0
- data/lib/project_types/script/cli.rb +17 -12
- data/lib/project_types/script/commands/push.rb +6 -2
- data/lib/project_types/script/config/extension_points.yml +2 -3
- data/lib/project_types/script/graphql/get_app_scripts.graphql +6 -0
- data/lib/project_types/script/layers/application/create_script.rb +2 -2
- data/lib/project_types/script/layers/application/push_script.rb +2 -1
- data/lib/project_types/script/layers/domain/errors.rb +0 -2
- data/lib/project_types/script/layers/domain/script_project.rb +17 -1
- data/lib/project_types/script/layers/infrastructure/command_runner.rb +19 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +12 -3
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +97 -0
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +103 -0
- data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +26 -0
- data/lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb +73 -0
- data/lib/project_types/script/layers/infrastructure/languages/rust_task_runner.rb +60 -0
- data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +21 -0
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +4 -5
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +22 -29
- data/lib/project_types/script/layers/infrastructure/script_service.rb +7 -1
- data/lib/project_types/script/messages/messages.rb +14 -4
- data/lib/project_types/script/tasks/ensure_env.rb +104 -0
- data/lib/project_types/script/ui/error_handler.rb +7 -6
- data/lib/shopify-cli/admin_api.rb +7 -4
- data/lib/shopify-cli/messages/messages.rb +48 -43
- data/lib/shopify-cli/method_object.rb +4 -4
- data/lib/shopify-cli/oauth.rb +7 -1
- data/lib/shopify-cli/partners_api.rb +7 -4
- data/lib/shopify-cli/partners_api/organizations.rb +3 -3
- data/lib/shopify-cli/resources/env_file.rb +1 -1
- data/lib/shopify-cli/shopifolk.rb +1 -1
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +6 -4
- data/lib/shopify-cli/tunnel.rb +22 -1
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +0 -1
- metadata +19 -11
- data/.travis.yml +0 -14
- data/lib/project_types/extension/features/argo_renderer_package.rb +0 -47
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +0 -100
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +0 -95
- data/lib/project_types/script/layers/infrastructure/project_creator.rb +0 -24
- data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +0 -72
- data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +0 -59
- data/lib/project_types/script/layers/infrastructure/task_runner.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f924d0de5639f7af794a6b35305b0bdcd78e2fad0f8a4c589006d249f48bbac
|
4
|
+
data.tar.gz: 701e91a9b522933b26f3a26baeab8f900a9cb3aa181e3b847b8a231c9edd5f04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96191b61830023526627944dcf5c4ac6a6b883aa060f81be3095cf5275763ef1552268cdcf46bc9d9b65cf9960ce879aa12b07cd799f2068f65329143a3149cc
|
7
|
+
data.tar.gz: 7e4d1e6c0c6b60609b661261cb0846acf5e42d58da4d525a8706df538c0ef3b7d55e9b26d45f8db8a6977aa5802d041bb639b0d4618718366333f2768f2dc1b8
|
@@ -29,3 +29,4 @@ Fixes #0000 <!-- link to issue if one exists -->
|
|
29
29
|
-->
|
30
30
|
- [ ] I've added a CHANGELOG entry for this PR (if the change is public-facing)
|
31
31
|
- [ ] I've considered possible cross-platform impacts (Mac, Linux, Windows).
|
32
|
+
- [ ] I've left the version number as is (we'll handle incrementing this when releasing).
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: Ruby ${{ matrix.version }}
|
8
|
+
runs-on: macos-latest
|
9
|
+
strategy:
|
10
|
+
matrix:
|
11
|
+
version:
|
12
|
+
- 3.0.0
|
13
|
+
- 2.6.6
|
14
|
+
- 2.7.1
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
|
18
|
+
- name: Set up Ruby ${{ matrix.version }}
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.version }}
|
22
|
+
bundler-cache: true
|
23
|
+
|
24
|
+
- name: Install Dependencies
|
25
|
+
run: bundle install
|
26
|
+
|
27
|
+
- name: Run Tests
|
28
|
+
run: bundle exec rake
|
@@ -15,12 +15,10 @@ jobs:
|
|
15
15
|
- uses: actions/checkout@v2
|
16
16
|
|
17
17
|
- name: Set up Ruby
|
18
|
-
uses:
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
19
|
with:
|
20
20
|
ruby-version: 2.6
|
21
|
-
|
22
|
-
- name: Install dependencies
|
23
|
-
run: bundle install
|
21
|
+
bundler-cache: true
|
24
22
|
|
25
23
|
- name: Create package
|
26
24
|
run: bundle exec rake package
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,34 @@
|
|
1
1
|
Unreleased
|
2
2
|
------
|
3
3
|
|
4
|
+
Version 1.13.1
|
5
|
+
--------------
|
6
|
+
* [1274](https://github.com/Shopify/shopify-app-cli/pull/1274): Only print api_key during error if it exists
|
7
|
+
* [1272](https://github.com/Shopify/shopify-app-cli/pull/1272): Fix minor bug with extension serve for UI extensions
|
8
|
+
|
9
|
+
Version 1.13.0
|
10
|
+
--------------
|
11
|
+
|
12
|
+
* [1266](https://github.com/Shopify/shopify-app-cli/pull/1266): Developer Console release
|
13
|
+
* [1265](https://github.com/Shopify/shopify-app-cli/pull/1265): Fix bug where commands hang after an unsuccessful authentication
|
14
|
+
|
15
|
+
Version 1.12.0
|
16
|
+
--------------
|
17
|
+
* [1255](https://github.com/Shopify/shopify-app-cli/pull/1255): Fix beta flag checks when running `shopify serve`
|
18
|
+
|
19
|
+
Version 1.11.0
|
20
|
+
--------------
|
21
|
+
* [#1221](https://github.com/Shopify/shopify-app-cli/pull/1221): Prioritizes returning an HTTPS URL over HTTP from `shopify tunnel status`.
|
22
|
+
* [#1223](https://github.com/Shopify/shopify-app-cli/pull/1233): Running `shopify serve` in an extension project now automatically runs `shopify tunnel`.
|
23
|
+
* [#1225](https://github.com/Shopify/shopify-app-cli/pull/1225): Improved handling of "account not found" scenario, plus improvements to related tests and UX messaging
|
24
|
+
* [#1229](https://github.com/Shopify/shopify-app-cli/pull/1229): Allows Checkout Extensions to specify configuration attributes in their extension.config.yml file.
|
25
|
+
* [#1238](https://github.com/Shopify/shopify-app-cli/pull/1238): Auto Tunnel Support for Checkout Extension
|
26
|
+
* [#1256](https://github.com/Shopify/shopify-app-cli/pull/1256): Allow using spaces around the equal sign on .env file.
|
27
|
+
|
28
|
+
Version 1.10.0
|
29
|
+
--------------
|
30
|
+
* Updating internal features in development
|
31
|
+
|
4
32
|
Version 1.9.1
|
5
33
|
-------------
|
6
34
|
* [1201](https://github.com/Shopify/shopify-app-cli/pull/1201) Determine Argo Renderer Dynamically. This fixes `shopify serve` and `shopify push` for extensions.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# [Shopify App CLI](https://shopify.dev/tools/cli)
|
2
2
|
|
3
|
-
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md)
|
3
|
+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md)
|
4
|
+
[![Build Status](https://github.com/Shopify/shopify-app-cli/workflows/CI/badge.svg)](https://github.com/Shopify/shopify-app-cli/actions)
|
4
5
|
|
5
6
|
Shopify App CLI helps you build Shopify apps faster. It quickly generates Node.js and Ruby on Rails apps and automates many common development tasks.
|
6
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Extension
|
4
|
-
class
|
4
|
+
class PackageResolutionFailed < RuntimeError; end
|
5
5
|
|
6
6
|
class Project < ShopifyCli::ProjectType
|
7
7
|
hidden_feature
|
@@ -38,6 +38,8 @@ module Extension
|
|
38
38
|
autoload :UpdateDraft, Project.project_filepath("tasks/update_draft")
|
39
39
|
autoload :FetchSpecifications, Project.project_filepath("tasks/fetch_specifications")
|
40
40
|
autoload :ConfigureFeatures, Project.project_filepath("tasks/configure_features")
|
41
|
+
autoload :ChooseNextAvailablePort, Project.project_filepath("tasks/choose_next_available_port")
|
42
|
+
autoload :FindNpmPackages, Project.project_filepath("tasks/find_npm_packages")
|
41
43
|
|
42
44
|
module Converters
|
43
45
|
autoload :RegistrationConverter, Project.project_filepath("tasks/converters/registration_converter")
|
@@ -59,13 +61,14 @@ module Extension
|
|
59
61
|
end
|
60
62
|
|
61
63
|
module Features
|
62
|
-
autoload :ArgoRendererPackage, Project.project_filepath("features/argo_renderer_package")
|
63
64
|
autoload :ArgoServe, Project.project_filepath("features/argo_serve")
|
65
|
+
autoload :ArgoServeOptions, Project.project_filepath("features/argo_serve_options")
|
64
66
|
autoload :ArgoSetup, Project.project_filepath("features/argo_setup")
|
65
67
|
autoload :ArgoSetupStep, Project.project_filepath("features/argo_setup_step")
|
66
68
|
autoload :ArgoSetupSteps, Project.project_filepath("features/argo_setup_steps")
|
67
69
|
autoload :ArgoDependencies, Project.project_filepath("features/argo_dependencies")
|
68
70
|
autoload :ArgoConfig, Project.project_filepath("features/argo_config")
|
71
|
+
autoload :ArgoRuntime, Project.project_filepath("features/argo_runtime")
|
69
72
|
autoload :Argo, Project.project_filepath("features/argo")
|
70
73
|
end
|
71
74
|
|
@@ -81,6 +84,7 @@ module Extension
|
|
81
84
|
autoload :Specification, Project.project_filepath("models/specification")
|
82
85
|
autoload :Specifications, Project.project_filepath("models/specifications")
|
83
86
|
autoload :LazySpecificationHandler, Project.project_filepath("models/lazy_specification_handler")
|
87
|
+
autoload :NpmPackage, Project.project_filepath("models/npm_package")
|
84
88
|
end
|
85
89
|
|
86
90
|
autoload :ExtensionProjectKeys, Project.project_filepath("extension_project_keys")
|
@@ -3,16 +3,84 @@
|
|
3
3
|
module Extension
|
4
4
|
module Commands
|
5
5
|
class Serve < ExtensionCommand
|
6
|
+
DEFAULT_PORT = 39351
|
7
|
+
|
8
|
+
options do |parser, flags|
|
9
|
+
parser.on("-t", "--[no-]tunnel", "Establish an ngrok tunnel") { |tunnel| flags[:tunnel] = tunnel }
|
10
|
+
end
|
11
|
+
|
12
|
+
class RuntimeConfiguration
|
13
|
+
include SmartProperties
|
14
|
+
|
15
|
+
property! :tunnel_url, accepts: String, default: ""
|
16
|
+
property! :tunnel_requested, accepts: [true, false], reader: :tunnel_requested?, default: true
|
17
|
+
property! :port, accepts: (1...(2**16)), default: DEFAULT_PORT
|
18
|
+
end
|
19
|
+
|
6
20
|
def call(_args, _command_name)
|
7
|
-
|
21
|
+
config = RuntimeConfiguration.new(
|
22
|
+
tunnel_requested: tunnel_requested?
|
23
|
+
)
|
24
|
+
|
25
|
+
ShopifyCli::Result
|
26
|
+
.success(config)
|
27
|
+
.then(&method(:find_available_port))
|
28
|
+
.then(&method(:start_tunnel_if_required))
|
29
|
+
.then(&method(:serve))
|
30
|
+
.unwrap { |error| raise error }
|
8
31
|
end
|
9
32
|
|
10
33
|
def self.help
|
11
34
|
<<~HELP
|
12
35
|
Serve your extension in a local simulator for development.
|
13
36
|
Usage: {{command:#{ShopifyCli::TOOL_NAME} serve}}
|
37
|
+
Options:
|
38
|
+
{{command:--tunnel=TUNNEL}} Establish an ngrok tunnel (default: false)
|
14
39
|
HELP
|
15
40
|
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def tunnel_requested?
|
45
|
+
tunnel = options.flags[:tunnel]
|
46
|
+
tunnel.nil? || !!tunnel
|
47
|
+
end
|
48
|
+
|
49
|
+
def find_available_port(runtime_configuration)
|
50
|
+
return runtime_configuration unless specification_handler.choose_port?(@ctx)
|
51
|
+
|
52
|
+
chosen_port = Tasks::ChooseNextAvailablePort
|
53
|
+
.call(from: runtime_configuration.port)
|
54
|
+
.unwrap { |_error| @ctx.abort(@ctx.message("serve.no_available_ports_found")) }
|
55
|
+
runtime_configuration.tap { |c| c.port = chosen_port }
|
56
|
+
end
|
57
|
+
|
58
|
+
def start_tunnel_if_required(runtime_configuration)
|
59
|
+
return runtime_configuration unless specification_handler.establish_tunnel?(@ctx)
|
60
|
+
return runtime_configuration unless runtime_configuration.tunnel_requested?
|
61
|
+
|
62
|
+
return start_tunnel(runtime_configuration) if can_start_tunnel?(runtime_configuration)
|
63
|
+
@ctx.abort(@ctx.message("serve.tunnel_already_running"))
|
64
|
+
end
|
65
|
+
|
66
|
+
def can_start_tunnel?(runtime_configuration)
|
67
|
+
return true if ShopifyCli::Tunnel.urls.empty?
|
68
|
+
ShopifyCli::Tunnel.running_on?(runtime_configuration.port)
|
69
|
+
end
|
70
|
+
|
71
|
+
def start_tunnel(runtime_configuration)
|
72
|
+
tunnel_url = ShopifyCli::Tunnel.start(@ctx, port: runtime_configuration.port)
|
73
|
+
runtime_configuration.tap { |c| c.tunnel_url = tunnel_url }
|
74
|
+
end
|
75
|
+
|
76
|
+
def serve(runtime_configuration)
|
77
|
+
specification_handler.serve(
|
78
|
+
context: @ctx,
|
79
|
+
tunnel_url: runtime_configuration.tunnel_url,
|
80
|
+
port: runtime_configuration.port
|
81
|
+
)
|
82
|
+
runtime_configuration
|
83
|
+
end
|
16
84
|
end
|
17
85
|
end
|
18
86
|
end
|
@@ -37,7 +37,9 @@ module Extension
|
|
37
37
|
private
|
38
38
|
|
39
39
|
def status
|
40
|
-
|
40
|
+
tunnel_urls = ShopifyCli::Tunnel.urls
|
41
|
+
tunnel_url = tunnel_urls.find { |url| url.start_with?("https://") }
|
42
|
+
tunnel_url = tunnel_urls.first if tunnel_url.nil?
|
41
43
|
|
42
44
|
if tunnel_url.nil?
|
43
45
|
@ctx.puts(@ctx.message("tunnel.no_tunnel_running"))
|
@@ -13,18 +13,22 @@ module Extension
|
|
13
13
|
|
14
14
|
SCRIPT_PATH = %w(build main.js).freeze
|
15
15
|
|
16
|
-
NPM_LIST_COMMAND = %w(list).freeze
|
17
|
-
YARN_LIST_COMMAND = %w(list).freeze
|
18
|
-
NPM_LIST_PARAMETERS = %w(--prod --depth=1).freeze
|
19
|
-
YARN_LIST_PARAMETERS = %w(--production).freeze
|
20
|
-
private_constant :NPM_LIST_COMMAND, :YARN_LIST_COMMAND, :NPM_LIST_PARAMETERS, :YARN_LIST_PARAMETERS
|
21
|
-
|
22
16
|
YARN_INSTALL_COMMAND = %w(install).freeze
|
23
17
|
YARN_INSTALL_PARAMETERS = %w(--silent).freeze
|
24
18
|
YARN_RUN_COMMAND = %w(run).freeze
|
25
19
|
YARN_RUN_SCRIPT_NAME = %w(build).freeze
|
26
20
|
private_constant :YARN_INSTALL_COMMAND, :YARN_INSTALL_PARAMETERS, :YARN_RUN_COMMAND, :YARN_RUN_SCRIPT_NAME
|
27
21
|
|
22
|
+
ARGO_CHECKOUT = "@shopify/argo-checkout"
|
23
|
+
ARGO_ADMIN = "@shopify/argo-admin"
|
24
|
+
ARGO_POST_PURCHASE = "@shopify/argo-post-purchase"
|
25
|
+
|
26
|
+
PACKAGE_NAMES = [
|
27
|
+
ARGO_CHECKOUT,
|
28
|
+
ARGO_ADMIN,
|
29
|
+
ARGO_POST_PURCHASE,
|
30
|
+
].freeze
|
31
|
+
|
28
32
|
def create(directory_name, identifier, context)
|
29
33
|
Features::ArgoSetup.new(git_template: git_template).call(directory_name, identifier, context)
|
30
34
|
end
|
@@ -48,8 +52,11 @@ module Extension
|
|
48
52
|
end
|
49
53
|
|
50
54
|
def renderer_package(context)
|
51
|
-
|
52
|
-
|
55
|
+
js_system = ShopifyCli::JsSystem.new(ctx: context)
|
56
|
+
Tasks::FindNpmPackages
|
57
|
+
.exactly_one_of(*PACKAGE_NAMES, js_system: js_system)
|
58
|
+
.unwrap { |err| raise err }
|
59
|
+
rescue Extension::PackageResolutionFailed
|
53
60
|
context.abort(
|
54
61
|
context.message("features.argo.dependencies.argo_missing_renderer_package_error")
|
55
62
|
)
|
@@ -57,22 +64,6 @@ module Extension
|
|
57
64
|
|
58
65
|
private
|
59
66
|
|
60
|
-
def run_list_command(context)
|
61
|
-
yarn_list = YARN_LIST_COMMAND + YARN_LIST_PARAMETERS
|
62
|
-
npm_list = NPM_LIST_COMMAND + NPM_LIST_PARAMETERS
|
63
|
-
|
64
|
-
result, error, status = ShopifyCli::JsSystem.call(
|
65
|
-
context,
|
66
|
-
yarn: yarn_list,
|
67
|
-
npm: npm_list,
|
68
|
-
capture_response: true
|
69
|
-
)
|
70
|
-
# context.abort(
|
71
|
-
# context.message("features.argo.dependencies.argo_missing_renderer_package_error", error)
|
72
|
-
# ) unless status.success?
|
73
|
-
result
|
74
|
-
end
|
75
|
-
|
76
67
|
def run_yarn_install(context, js_system)
|
77
68
|
_result, error, status = js_system.call(
|
78
69
|
yarn: YARN_INSTALL_COMMAND + YARN_INSTALL_PARAMETERS,
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Extension
|
2
|
+
module Features
|
3
|
+
class ArgoRuntime
|
4
|
+
include SmartProperties
|
5
|
+
|
6
|
+
ARGO_RUN_PACKAGE_NAME = "@shopify/argo-run"
|
7
|
+
ARGO_ADMIN_CLI_PACKAGE_NAME = "@shopify/argo-admin-cli"
|
8
|
+
|
9
|
+
ARGO_RUN_0_4_0 = Models::NpmPackage.new(name: "@shopify/argo-run", version: "0.4.0")
|
10
|
+
ARGO_ADMIN_CLI_0_9_0 = Models::NpmPackage.new(name: "@shopify/argo-admin-cli", version: "0.9.0")
|
11
|
+
ARGO_ADMIN_CLI_0_9_3 = Models::NpmPackage.new(name: "@shopify/argo-admin-cli", version: "0.9.3")
|
12
|
+
ARGO_ADMIN_CLI_0_11_0 = Models::NpmPackage.new(name: "@shopify/argo-admin-cli", version: "0.11.0")
|
13
|
+
|
14
|
+
property! :renderer, accepts: Models::NpmPackage
|
15
|
+
property! :cli, accepts: Models::NpmPackage
|
16
|
+
|
17
|
+
def accepts_port?
|
18
|
+
case cli
|
19
|
+
when admin?
|
20
|
+
cli >= ARGO_ADMIN_CLI_0_11_0
|
21
|
+
when checkout?
|
22
|
+
cli >= ARGO_RUN_0_4_0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def accepts_tunnel_url?
|
27
|
+
case cli
|
28
|
+
when admin?
|
29
|
+
cli >= ARGO_ADMIN_CLI_0_11_0
|
30
|
+
when checkout?
|
31
|
+
cli >= ARGO_RUN_0_4_0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def accepts_uuid?
|
36
|
+
case cli
|
37
|
+
when admin?
|
38
|
+
cli >= ARGO_ADMIN_CLI_0_11_0
|
39
|
+
else
|
40
|
+
false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def accepts_argo_version?
|
45
|
+
case cli
|
46
|
+
when admin?
|
47
|
+
cli >= ARGO_ADMIN_CLI_0_9_3
|
48
|
+
else
|
49
|
+
false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def accepts_shop?
|
54
|
+
case cli
|
55
|
+
when admin?
|
56
|
+
cli >= ARGO_ADMIN_CLI_0_11_0
|
57
|
+
else
|
58
|
+
false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def accepts_api_key?
|
63
|
+
case cli
|
64
|
+
when admin?
|
65
|
+
cli >= ARGO_ADMIN_CLI_0_11_0
|
66
|
+
else
|
67
|
+
false
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def accepts_name?
|
72
|
+
case cli
|
73
|
+
when admin?
|
74
|
+
cli >= ARGO_ADMIN_CLI_0_9_0
|
75
|
+
else
|
76
|
+
false
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def admin?
|
83
|
+
->(cli) { cli.name == ARGO_ADMIN_CLI_PACKAGE_NAME }
|
84
|
+
end
|
85
|
+
|
86
|
+
def checkout?
|
87
|
+
->(cli) { cli.name == ARGO_RUN_PACKAGE_NAME }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -4,32 +4,59 @@ module Extension
|
|
4
4
|
include SmartProperties
|
5
5
|
|
6
6
|
property! :specification_handler, accepts: Extension::Models::SpecificationHandlers::Default
|
7
|
+
property! :argo_runtime, accepts: Features::ArgoRuntime
|
7
8
|
property! :context, accepts: ShopifyCli::Context
|
8
|
-
|
9
|
-
|
10
|
-
NPM_SERVE_COMMAND = %w(run-script server)
|
9
|
+
property! :port, accepts: Integer, default: 39351
|
10
|
+
property :tunnel_url, accepts: String, default: ""
|
11
11
|
|
12
12
|
def call
|
13
13
|
validate_env!
|
14
14
|
|
15
15
|
CLI::UI::Frame.open(context.message("serve.frame_title")) do
|
16
|
-
success =
|
16
|
+
success = call_js_system(yarn_command: yarn_serve_command, npm_command: npm_serve_command)
|
17
17
|
context.abort(context.message("serve.serve_failure_message")) unless success
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
+
def call_js_system(yarn_command:, npm_command:)
|
24
|
+
ShopifyCli::JsSystem.call(context, yarn: yarn_command, npm: npm_command)
|
25
|
+
end
|
26
|
+
|
23
27
|
def specification
|
24
28
|
specification_handler.specification
|
25
29
|
end
|
26
30
|
|
27
|
-
def
|
28
|
-
|
31
|
+
def renderer_package
|
32
|
+
specification_handler.renderer_package(context)
|
33
|
+
end
|
34
|
+
|
35
|
+
def required_fields
|
36
|
+
specification.features.argo.required_fields
|
37
|
+
end
|
29
38
|
|
30
|
-
|
39
|
+
def serve_options
|
40
|
+
@options ||= Features::ArgoServeOptions.new(
|
41
|
+
argo_runtime: argo_runtime,
|
42
|
+
port: port,
|
43
|
+
context: context,
|
44
|
+
required_fields: required_fields,
|
45
|
+
renderer_package: renderer_package,
|
46
|
+
public_url: tunnel_url
|
47
|
+
)
|
48
|
+
end
|
31
49
|
|
32
|
-
|
50
|
+
def yarn_serve_command
|
51
|
+
serve_options.yarn_serve_command
|
52
|
+
end
|
53
|
+
|
54
|
+
def npm_serve_command
|
55
|
+
serve_options.npm_serve_command
|
56
|
+
end
|
57
|
+
|
58
|
+
def validate_env!
|
59
|
+
ExtensionProject.reload
|
33
60
|
|
34
61
|
return if required_fields.none?
|
35
62
|
|
@@ -45,25 +72,6 @@ module Extension
|
|
45
72
|
|
46
73
|
context.abort(context.message("serve.serve_missing_information"))
|
47
74
|
end
|
48
|
-
|
49
|
-
def yarn_serve_command
|
50
|
-
YARN_SERVE_COMMAND + serve_options(specification.features.argo.required_fields)
|
51
|
-
end
|
52
|
-
|
53
|
-
def npm_serve_command
|
54
|
-
NPM_SERVE_COMMAND + ["--"] + serve_options(specification.features.argo.required_fields)
|
55
|
-
end
|
56
|
-
|
57
|
-
def serve_options(required_fields)
|
58
|
-
renderer_package = specification_handler.renderer_package(context)
|
59
|
-
project = ExtensionProject.current
|
60
|
-
@serve_options ||= [].tap do |options|
|
61
|
-
options << "--shop=#{project.env.shop}" if required_fields.include?(:shop)
|
62
|
-
options << "--apiKey=#{project.env.api_key}" if required_fields.include?(:api_key)
|
63
|
-
options << "--argoVersion=#{renderer_package.version}" if renderer_package.admin?
|
64
|
-
options << "--uuid=#{project.registration_uuid}" if renderer_package.supports_uuid_flag?
|
65
|
-
end
|
66
|
-
end
|
67
75
|
end
|
68
76
|
end
|
69
77
|
end
|