shopify-cli 1.10.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +1 -0
- data/.github/workflows/release.yml +2 -4
- data/CHANGELOG.md +31 -1
- data/Gemfile.lock +1 -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 +3 -0
- 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 +14 -13
- data/lib/project_types/script/commands/push.rb +8 -3
- data/lib/project_types/script/config/extension_points.yml +0 -3
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +9 -3
- data/lib/project_types/script/layers/application/create_script.rb +6 -5
- data/lib/project_types/script/layers/application/push_script.rb +2 -1
- data/lib/project_types/script/layers/domain/errors.rb +6 -13
- data/lib/project_types/script/layers/domain/push_package.rb +4 -8
- data/lib/project_types/script/layers/domain/script_json.rb +32 -0
- data/lib/project_types/script/layers/domain/script_project.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/command_runner.rb +19 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +25 -20
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +105 -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 +6 -8
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +44 -59
- data/lib/project_types/script/layers/infrastructure/script_service.rb +21 -15
- data/lib/project_types/script/messages/messages.rb +28 -22
- data/lib/project_types/script/tasks/ensure_env.rb +32 -3
- data/lib/project_types/script/ui/error_handler.rb +37 -36
- data/lib/shopify-cli/admin_api.rb +7 -4
- data/lib/shopify-cli/context.rb +13 -0
- 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
- metadata +17 -11
- data/lib/project_types/extension/features/argo_renderer_package.rb +0 -47
- data/lib/project_types/script/layers/domain/config_ui.rb +0 -16
- 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: d8f8161eea7a180b04614de6e548d11126711cdeabb05f7eb85c1d35cc6c1769
|
4
|
+
data.tar.gz: e07cb22654f647771d78d1aad39514534fcc2817a01a16f24e03b896828ca583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24bb19308430c1fab1336af24b68182e63223bb24e62eb98c551a7bf34a23f8dc615c0ebe4b74381458085101316f47ec467d37192b28d86d528ef3020d6b220
|
7
|
+
data.tar.gz: f7afb287929f611361137c909846f5f64e8fc58dbfaffa460c37b3b64deae46f33d79d7201bb23f2819de3da2b4b9666ce1fc9d08f6993a91872a0dffaf1ce83
|
@@ -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).
|
@@ -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,8 +1,38 @@
|
|
1
1
|
Unreleased
|
2
2
|
------
|
3
3
|
|
4
|
+
Version 1.14.0
|
5
|
+
--------------
|
6
|
+
* [1275](https://github.com/Shopify/shopify-app-cli/pull/1275): Use script.json to specify script metadata
|
7
|
+
* [1279](https://github.com/Shopify/shopify-app-cli/pull/1279): Fix bug where a script push still fails after the user answers the force push prompt
|
8
|
+
* [1288](https://github.com/Shopify/shopify-app-cli/pull/1288): Fix bug where Scripts SDK was included for projects that don't require it
|
9
|
+
|
10
|
+
Version 1.13.1
|
11
|
+
--------------
|
12
|
+
* [1274](https://github.com/Shopify/shopify-app-cli/pull/1274): Only print api_key during error if it exists
|
13
|
+
* [1272](https://github.com/Shopify/shopify-app-cli/pull/1272): Fix minor bug with extension serve for UI extensions
|
14
|
+
|
15
|
+
Version 1.13.0
|
16
|
+
--------------
|
17
|
+
|
18
|
+
* [1266](https://github.com/Shopify/shopify-app-cli/pull/1266): Developer Console release
|
19
|
+
* [1265](https://github.com/Shopify/shopify-app-cli/pull/1265): Fix bug where commands hang after an unsuccessful authentication
|
20
|
+
|
21
|
+
Version 1.12.0
|
22
|
+
--------------
|
23
|
+
* [1255](https://github.com/Shopify/shopify-app-cli/pull/1255): Fix beta flag checks when running `shopify serve`
|
24
|
+
|
25
|
+
Version 1.11.0
|
26
|
+
--------------
|
27
|
+
* [#1221](https://github.com/Shopify/shopify-app-cli/pull/1221): Prioritizes returning an HTTPS URL over HTTP from `shopify tunnel status`.
|
28
|
+
* [#1223](https://github.com/Shopify/shopify-app-cli/pull/1233): Running `shopify serve` in an extension project now automatically runs `shopify tunnel`.
|
29
|
+
* [#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
|
30
|
+
* [#1229](https://github.com/Shopify/shopify-app-cli/pull/1229): Allows Checkout Extensions to specify configuration attributes in their extension.config.yml file.
|
31
|
+
* [#1238](https://github.com/Shopify/shopify-app-cli/pull/1238): Auto Tunnel Support for Checkout Extension
|
32
|
+
* [#1256](https://github.com/Shopify/shopify-app-cli/pull/1256): Allow using spaces around the equal sign on .env file.
|
33
|
+
|
4
34
|
Version 1.10.0
|
5
|
-
|
35
|
+
--------------
|
6
36
|
* Updating internal features in development
|
7
37
|
|
8
38
|
Version 1.9.1
|
data/Gemfile.lock
CHANGED
@@ -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
|