shopify-cli 1.9.0 → 1.13.0
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 +27 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/project_types/extension/cli.rb +7 -1
- 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 +18 -49
- data/lib/project_types/extension/features/argo_runtime.rb +81 -0
- data/lib/project_types/extension/features/argo_serve.rb +35 -27
- data/lib/project_types/extension/features/argo_serve_options.rb +41 -0
- data/lib/project_types/extension/features/argo_setup.rb +1 -1
- data/lib/project_types/extension/messages/messages.rb +5 -4
- data/lib/project_types/extension/models/npm_package.rb +14 -0
- data/lib/project_types/extension/models/specification.rb +3 -2
- 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/models/version.rb +1 -1
- 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/node/messages/messages.rb +4 -4
- data/lib/project_types/rails/messages/messages.rb +4 -4
- data/lib/project_types/script/cli.rb +17 -12
- data/lib/project_types/script/commands/push.rb +1 -1
- data/lib/project_types/script/config/extension_points.yml +2 -3
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +5 -2
- 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 +6 -3
- data/lib/project_types/script/layers/domain/errors.rb +0 -2
- data/lib/project_types/script/layers/domain/push_package.rb +4 -0
- data/lib/project_types/script/layers/domain/script_project.rb +21 -1
- data/lib/project_types/script/layers/infrastructure/command_runner.rb +19 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +30 -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 +6 -5
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +61 -34
- data/lib/project_types/script/layers/infrastructure/script_service.rb +14 -2
- data/lib/project_types/script/messages/messages.rb +20 -3
- data/lib/project_types/script/tasks/ensure_env.rb +85 -0
- data/lib/project_types/script/ui/error_handler.rb +25 -6
- data/lib/shopify-cli/admin_api.rb +7 -4
- data/lib/shopify-cli/js_system.rb +2 -2
- data/lib/shopify-cli/messages/messages.rb +51 -45
- data/lib/shopify-cli/method_object.rb +4 -4
- data/lib/shopify-cli/oauth.rb +9 -3
- data/lib/shopify-cli/packager.rb +1 -1
- data/lib/shopify-cli/partners_api.rb +7 -4
- data/lib/shopify-cli/partners_api/organizations.rb +3 -3
- data/lib/shopify-cli/resolve_constant.rb +1 -1
- data/lib/shopify-cli/resources/env_file.rb +2 -2
- data/lib/shopify-cli/shopifolk.rb +1 -1
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +6 -4
- data/lib/shopify-cli/transform_data_structure.rb +1 -1
- data/lib/shopify-cli/tunnel.rb +22 -1
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +0 -1
- data/vendor/deps/smart_properties/REVISION +1 -1
- data/vendor/deps/smart_properties/lib/smart_properties/property.rb +7 -1
- data/vendor/deps/smart_properties/lib/smart_properties/version.rb +1 -1
- metadata +19 -11
- data/.travis.yml +0 -14
- data/lib/project_types/extension/features/argo_renderer_package.rb +0 -32
- 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
data/lib/shopify-cli/packager.rb
CHANGED
@@ -99,7 +99,7 @@ module ShopifyCli
|
|
99
99
|
raise <<~MESSAGE
|
100
100
|
|
101
101
|
Could not find program #{program} which is required to build the package.
|
102
|
-
You can install it by running
|
102
|
+
You can install it by running #{installation_cmd}.
|
103
103
|
|
104
104
|
MESSAGE
|
105
105
|
end
|
@@ -59,11 +59,14 @@ module ShopifyCli
|
|
59
59
|
|
60
60
|
private
|
61
61
|
|
62
|
-
def authenticated_req(ctx)
|
63
|
-
|
62
|
+
def authenticated_req(ctx, &block)
|
63
|
+
CLI::Kit::Util
|
64
|
+
.begin(&block)
|
65
|
+
.retry_after(API::APIRequestUnauthorizedError, retries: 1) do
|
66
|
+
authenticate(ctx)
|
67
|
+
end
|
64
68
|
rescue API::APIRequestUnauthorizedError
|
65
|
-
|
66
|
-
retry
|
69
|
+
ctx.abort(ctx.message("core.api.error.failed_auth"))
|
67
70
|
rescue API::APIRequestNotFoundError
|
68
71
|
ctx.puts(ctx.message("core.partners_api.error.account_not_found", ShopifyCli::TOOL_NAME))
|
69
72
|
end
|
@@ -4,7 +4,7 @@ module ShopifyCli
|
|
4
4
|
class << self
|
5
5
|
def fetch_all(ctx)
|
6
6
|
resp = PartnersAPI.query(ctx, "all_organizations")
|
7
|
-
(resp
|
7
|
+
(resp&.dig("data", "organizations", "nodes") || []).map do |org|
|
8
8
|
org["stores"] = (org.dig("stores", "nodes") || [])
|
9
9
|
org
|
10
10
|
end
|
@@ -12,7 +12,7 @@ module ShopifyCli
|
|
12
12
|
|
13
13
|
def fetch(ctx, id:)
|
14
14
|
resp = PartnersAPI.query(ctx, "find_organization", id: id)
|
15
|
-
org = resp
|
15
|
+
org = resp&.dig("data", "organizations", "nodes")&.first
|
16
16
|
return nil if org.nil?
|
17
17
|
org["stores"] = (org.dig("stores", "nodes") || [])
|
18
18
|
org
|
@@ -20,7 +20,7 @@ module ShopifyCli
|
|
20
20
|
|
21
21
|
def fetch_with_app(ctx)
|
22
22
|
resp = PartnersAPI.query(ctx, "all_orgs_with_apps")
|
23
|
-
(resp
|
23
|
+
(resp&.dig("data", "organizations", "nodes") || []).map do |org|
|
24
24
|
org["stores"] = (org.dig("stores", "nodes") || [])
|
25
25
|
org["apps"] = (org.dig("apps", "nodes") || [])
|
26
26
|
org
|
@@ -11,7 +11,7 @@
|
|
11
11
|
module ShopifyCli
|
12
12
|
class ResolveConstant
|
13
13
|
include ShopifyCli::MethodObject
|
14
|
-
property! :namespace, accepts: ->(ns) { ns.respond_to?(:const_get) }, default: Kernel
|
14
|
+
property! :namespace, accepts: ->(ns) { ns.respond_to?(:const_get) }, default: -> { Kernel }
|
15
15
|
|
16
16
|
def call(name)
|
17
17
|
name
|
@@ -22,7 +22,7 @@ module ShopifyCli
|
|
22
22
|
def parse(directory)
|
23
23
|
File.read(File.join(directory, FILENAME))
|
24
24
|
.gsub("\r\n", "\n").split("\n").each_with_object({}) do |line, output|
|
25
|
-
match = /\A([A-Za-z_0-9]+)
|
25
|
+
match = /\A([A-Za-z_0-9]+)\s*=\s*(.*)\z/.match(line)
|
26
26
|
if match
|
27
27
|
key = match[1]
|
28
28
|
output[key] = case match[2]
|
@@ -57,7 +57,7 @@ module ShopifyCli
|
|
57
57
|
property :shop
|
58
58
|
property :scopes
|
59
59
|
property :host
|
60
|
-
property :extra, default: {}
|
60
|
+
property :extra, default: -> { {} }
|
61
61
|
|
62
62
|
def to_h
|
63
63
|
out = {}
|
@@ -33,7 +33,7 @@ module ShopifyCli
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def acting_as_shopify_organization?
|
36
|
-
|
36
|
+
!!(@acting_as_shopify_organization || (Project.has_current? && Project.current.config["shopify_organization"]))
|
37
37
|
end
|
38
38
|
|
39
39
|
def reset
|
@@ -35,14 +35,16 @@ module ShopifyCli
|
|
35
35
|
@organization ||= if !organization_id.nil?
|
36
36
|
org = ShopifyCli::PartnersAPI::Organizations.fetch(ctx, id: organization_id)
|
37
37
|
if org.nil?
|
38
|
-
ctx.puts(ctx.message("core.tasks.select_org_and_shop.
|
38
|
+
ctx.puts(ctx.message("core.tasks.select_org_and_shop.authentication_issue", ShopifyCli::TOOL_NAME))
|
39
39
|
ctx.abort(ctx.message("core.tasks.select_org_and_shop.error.organization_not_found"))
|
40
40
|
end
|
41
41
|
org
|
42
42
|
elsif organizations.count == 0
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
if Shopifolk.acting_as_shopify_organization?
|
44
|
+
ctx.abort(ctx.message("core.tasks.select_org_and_shop.error.shopifolk_notice", ShopifyCli::TOOL_NAME))
|
45
|
+
else
|
46
|
+
ctx.abort(ctx.message("core.tasks.select_org_and_shop.error.no_organizations"))
|
47
|
+
end
|
46
48
|
elsif organizations.count == 1
|
47
49
|
org = organizations.first
|
48
50
|
ctx.puts(ctx.message("core.tasks.select_org_and_shop.organization", org["businessName"], org["id"]))
|
@@ -42,7 +42,7 @@ module ShopifyCli
|
|
42
42
|
property! :symbolize_keys, accepts: [true, false], default: false, reader: :symbolize_keys?
|
43
43
|
property! :associative_array_container,
|
44
44
|
accepts: ->(c) { c.respond_to?(:new) && c.method_defined?(:[]=) },
|
45
|
-
default: Hash
|
45
|
+
default: -> { Hash }
|
46
46
|
|
47
47
|
def call(object)
|
48
48
|
case object
|
data/lib/shopify-cli/tunnel.rb
CHANGED
@@ -2,6 +2,7 @@ require "json"
|
|
2
2
|
require "fileutils"
|
3
3
|
require "shopify_cli"
|
4
4
|
require "forwardable"
|
5
|
+
require "uri"
|
5
6
|
|
6
7
|
module ShopifyCli
|
7
8
|
##
|
@@ -11,7 +12,7 @@ module ShopifyCli
|
|
11
12
|
class Tunnel
|
12
13
|
extend SingleForwardable
|
13
14
|
|
14
|
-
def_delegators :new, :start, :stop, :auth, :stats, :urls
|
15
|
+
def_delegators :new, :start, :stop, :auth, :stats, :urls, :running_on?
|
15
16
|
|
16
17
|
class FetchUrlError < RuntimeError; end
|
17
18
|
class NgrokError < RuntimeError; end
|
@@ -26,6 +27,7 @@ module ShopifyCli
|
|
26
27
|
|
27
28
|
NGROK_TUNNELS_URI = URI.parse("http://localhost:4040/api/tunnels")
|
28
29
|
TUNNELS_FIELD = "tunnels"
|
30
|
+
TUNNEL_ADDRESS_KEY_PATH = ["config", "addr"]
|
29
31
|
PUBLIC_URL_FIELD = "public_url"
|
30
32
|
|
31
33
|
##
|
@@ -120,6 +122,25 @@ module ShopifyCli
|
|
120
122
|
[]
|
121
123
|
end
|
122
124
|
|
125
|
+
##
|
126
|
+
# Returns Boolean if a tunnel is running on a given port
|
127
|
+
#
|
128
|
+
# #### Parameters
|
129
|
+
#
|
130
|
+
# * `port` - port to check
|
131
|
+
#
|
132
|
+
# #### Returns
|
133
|
+
#
|
134
|
+
# * true / false
|
135
|
+
#
|
136
|
+
def running_on?(port)
|
137
|
+
extract_port = ->(tunnel) { URI(tunnel.dig(*TUNNEL_ADDRESS_KEY_PATH)).port }
|
138
|
+
matches_port = ->(occupied_port) { occupied_port == port }
|
139
|
+
stats.fetch(TUNNELS_FIELD, []).map(&extract_port).any?(&matches_port)
|
140
|
+
rescue
|
141
|
+
false
|
142
|
+
end
|
143
|
+
|
123
144
|
private
|
124
145
|
|
125
146
|
def install(ctx)
|
data/lib/shopify-cli/version.rb
CHANGED
data/lib/shopify_cli.rb
CHANGED
@@ -110,7 +110,6 @@ module ShopifyCli
|
|
110
110
|
autoload :JsSystem, "shopify-cli/js_system"
|
111
111
|
autoload :MethodObject, "shopify-cli/method_object"
|
112
112
|
autoload :LazyDelegator, "shopify-cli/lazy_delegator"
|
113
|
-
autoload :Log, "shopify-cli/log"
|
114
113
|
autoload :OAuth, "shopify-cli/oauth"
|
115
114
|
autoload :Options, "shopify-cli/options"
|
116
115
|
autoload :PartnersAPI, "shopify-cli/partners_api"
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
cfe83ef361e68ba7c471af75144f2b85cf1e1ec6
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module SmartProperties
|
2
2
|
class Property
|
3
3
|
MODULE_REFERENCE = :"@_smart_properties_method_scope"
|
4
|
+
ALLOWED_DEFAULT_CLASSES = [Proc, Numeric, String, Range, TrueClass, FalseClass, NilClass, Symbol, Module].freeze
|
4
5
|
|
5
6
|
attr_reader :name
|
6
7
|
attr_reader :converter
|
@@ -27,6 +28,11 @@ module SmartProperties
|
|
27
28
|
|
28
29
|
@instance_variable_name = :"@#{name}"
|
29
30
|
|
31
|
+
unless ALLOWED_DEFAULT_CLASSES.any? { |cls| @default.is_a?(cls) }
|
32
|
+
raise ConfigurationError, "Default attribute value #{@default.inspect} cannot be specified as literal, "\
|
33
|
+
"use the syntax `default: -> { ... }` instead."
|
34
|
+
end
|
35
|
+
|
30
36
|
unless attrs.empty?
|
31
37
|
raise ConfigurationError, "SmartProperties do not support the following configuration options: #{attrs.keys.map { |m| m.to_s }.sort.join(', ')}."
|
32
38
|
end
|
@@ -66,7 +72,7 @@ module SmartProperties
|
|
66
72
|
end
|
67
73
|
|
68
74
|
def default(scope)
|
69
|
-
@default.kind_of?(Proc) ? scope.instance_exec(&@default) : @default
|
75
|
+
@default.kind_of?(Proc) ? scope.instance_exec(&@default) : @default.dup
|
70
76
|
end
|
71
77
|
|
72
78
|
def accepts?(value, scope)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- ".github/ISSUE_TEMPLATE.md"
|
78
78
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
79
79
|
- ".github/probots.yml"
|
80
|
+
- ".github/workflows/build.yml"
|
80
81
|
- ".github/workflows/release.yml"
|
81
82
|
- ".github/workflows/triage.yml"
|
82
83
|
- ".gitignore"
|
@@ -85,7 +86,6 @@ files:
|
|
85
86
|
- ".ruby-version"
|
86
87
|
- ".tmp/.gitkeep"
|
87
88
|
- ".tmp/sv/.gitkeep"
|
88
|
-
- ".travis.yml"
|
89
89
|
- CHANGELOG.md
|
90
90
|
- Gemfile
|
91
91
|
- Gemfile.lock
|
@@ -144,8 +144,9 @@ files:
|
|
144
144
|
- lib/project_types/extension/features/argo.rb
|
145
145
|
- lib/project_types/extension/features/argo_config.rb
|
146
146
|
- lib/project_types/extension/features/argo_dependencies.rb
|
147
|
-
- lib/project_types/extension/features/
|
147
|
+
- lib/project_types/extension/features/argo_runtime.rb
|
148
148
|
- lib/project_types/extension/features/argo_serve.rb
|
149
|
+
- lib/project_types/extension/features/argo_serve_options.rb
|
149
150
|
- lib/project_types/extension/features/argo_setup.rb
|
150
151
|
- lib/project_types/extension/features/argo_setup_step.rb
|
151
152
|
- lib/project_types/extension/features/argo_setup_steps.rb
|
@@ -157,13 +158,16 @@ files:
|
|
157
158
|
- lib/project_types/extension/messages/messages.rb
|
158
159
|
- lib/project_types/extension/models/app.rb
|
159
160
|
- lib/project_types/extension/models/lazy_specification_handler.rb
|
161
|
+
- lib/project_types/extension/models/npm_package.rb
|
160
162
|
- lib/project_types/extension/models/registration.rb
|
161
163
|
- lib/project_types/extension/models/specification.rb
|
164
|
+
- lib/project_types/extension/models/specification_handlers/checkout_argo_extension.rb
|
162
165
|
- lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb
|
163
166
|
- lib/project_types/extension/models/specification_handlers/default.rb
|
164
167
|
- lib/project_types/extension/models/specifications.rb
|
165
168
|
- lib/project_types/extension/models/validation_error.rb
|
166
169
|
- lib/project_types/extension/models/version.rb
|
170
|
+
- lib/project_types/extension/tasks/choose_next_available_port.rb
|
167
171
|
- lib/project_types/extension/tasks/configure_features.rb
|
168
172
|
- lib/project_types/extension/tasks/converters/app_converter.rb
|
169
173
|
- lib/project_types/extension/tasks/converters/registration_converter.rb
|
@@ -171,6 +175,7 @@ files:
|
|
171
175
|
- lib/project_types/extension/tasks/converters/version_converter.rb
|
172
176
|
- lib/project_types/extension/tasks/create_extension.rb
|
173
177
|
- lib/project_types/extension/tasks/fetch_specifications.rb
|
178
|
+
- lib/project_types/extension/tasks/find_npm_packages.rb
|
174
179
|
- lib/project_types/extension/tasks/get_app.rb
|
175
180
|
- lib/project_types/extension/tasks/get_apps.rb
|
176
181
|
- lib/project_types/extension/tasks/update_draft.rb
|
@@ -215,6 +220,7 @@ files:
|
|
215
220
|
- lib/project_types/script/errors.rb
|
216
221
|
- lib/project_types/script/forms/create.rb
|
217
222
|
- lib/project_types/script/graphql/app_script_update_or_create.graphql
|
223
|
+
- lib/project_types/script/graphql/get_app_scripts.graphql
|
218
224
|
- lib/project_types/script/graphql/script_service_proxy.graphql
|
219
225
|
- lib/project_types/script/layers/application/build_script.rb
|
220
226
|
- lib/project_types/script/layers/application/create_script.rb
|
@@ -227,18 +233,20 @@ files:
|
|
227
233
|
- lib/project_types/script/layers/domain/metadata.rb
|
228
234
|
- lib/project_types/script/layers/domain/push_package.rb
|
229
235
|
- lib/project_types/script/layers/domain/script_project.rb
|
230
|
-
- lib/project_types/script/layers/infrastructure/
|
231
|
-
- lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb
|
236
|
+
- lib/project_types/script/layers/infrastructure/command_runner.rb
|
232
237
|
- lib/project_types/script/layers/infrastructure/errors.rb
|
233
238
|
- lib/project_types/script/layers/infrastructure/extension_point_repository.rb
|
234
|
-
- lib/project_types/script/layers/infrastructure/
|
239
|
+
- lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb
|
240
|
+
- lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb
|
241
|
+
- lib/project_types/script/layers/infrastructure/languages/project_creator.rb
|
242
|
+
- lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb
|
243
|
+
- lib/project_types/script/layers/infrastructure/languages/rust_task_runner.rb
|
244
|
+
- lib/project_types/script/layers/infrastructure/languages/task_runner.rb
|
235
245
|
- lib/project_types/script/layers/infrastructure/push_package_repository.rb
|
236
|
-
- lib/project_types/script/layers/infrastructure/rust_project_creator.rb
|
237
|
-
- lib/project_types/script/layers/infrastructure/rust_task_runner.rb
|
238
246
|
- lib/project_types/script/layers/infrastructure/script_project_repository.rb
|
239
247
|
- lib/project_types/script/layers/infrastructure/script_service.rb
|
240
|
-
- lib/project_types/script/layers/infrastructure/task_runner.rb
|
241
248
|
- lib/project_types/script/messages/messages.rb
|
249
|
+
- lib/project_types/script/tasks/ensure_env.rb
|
242
250
|
- lib/project_types/script/ui/error_handler.rb
|
243
251
|
- lib/project_types/script/ui/printing_spinner.rb
|
244
252
|
- lib/project_types/script/ui/strict_spinner.rb
|
@@ -463,7 +471,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
463
471
|
- !ruby/object:Gem::Version
|
464
472
|
version: '0'
|
465
473
|
requirements: []
|
466
|
-
rubygems_version: 3.
|
474
|
+
rubygems_version: 3.2.17
|
467
475
|
signing_key:
|
468
476
|
specification_version: 4
|
469
477
|
summary: Shopify CLI helps you build Shopify apps faster.
|
data/.travis.yml
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
module Extension
|
2
|
-
module Features
|
3
|
-
class ArgoRendererPackage
|
4
|
-
include SmartProperties
|
5
|
-
|
6
|
-
ARGO_CHECKOUT = "@shopify/argo-checkout"
|
7
|
-
ARGO_ADMIN = "@shopify/argo-admin"
|
8
|
-
|
9
|
-
PACKAGE_NAMES = [
|
10
|
-
ARGO_CHECKOUT,
|
11
|
-
ARGO_ADMIN,
|
12
|
-
].freeze
|
13
|
-
MINIMUM_ARGO_VERSION = "0.9.3".freeze
|
14
|
-
|
15
|
-
property! :package_name, accepts: PACKAGE_NAMES
|
16
|
-
property! :version, accepts: String
|
17
|
-
|
18
|
-
def checkout?
|
19
|
-
package_name == ARGO_CHECKOUT
|
20
|
-
end
|
21
|
-
|
22
|
-
def admin?
|
23
|
-
package_name == ARGO_ADMIN
|
24
|
-
end
|
25
|
-
|
26
|
-
def supports_uuid_flag?
|
27
|
-
return false if checkout?
|
28
|
-
Gem::Version.new(version) > Gem::Version.new(MINIMUM_ARGO_VERSION)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
class AssemblyScriptProjectCreator
|
7
|
-
include SmartProperties
|
8
|
-
property! :ctx, accepts: ShopifyCli::Context
|
9
|
-
property! :extension_point, accepts: Domain::ExtensionPoint
|
10
|
-
property! :script_name, accepts: String
|
11
|
-
property! :path_to_project, accepts: String
|
12
|
-
|
13
|
-
BOOTSTRAP = "npx --no-install shopify-scripts-toolchain-as bootstrap --from %{extension_point} --dest %{base}"
|
14
|
-
BUILD = "shopify-scripts-toolchain-as build --src src/shopify_main.ts " \
|
15
|
-
"--binary build/%{script_name}.wasm --metadata build/metadata.json"
|
16
|
-
MIN_NODE_VERSION = "14.5.0"
|
17
|
-
ASC_ARGS = "-- --lib node_modules --optimize --use Date="
|
18
|
-
|
19
|
-
def setup_dependencies
|
20
|
-
write_npmrc
|
21
|
-
write_package_json
|
22
|
-
end
|
23
|
-
|
24
|
-
def bootstrap
|
25
|
-
out, status = ctx.capture2e(bootstap_command)
|
26
|
-
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def write_npmrc
|
32
|
-
ctx.system(
|
33
|
-
"npm", "--userconfig", "./.npmrc", "config", "set", "@shopify:registry", "https://registry.npmjs.com"
|
34
|
-
)
|
35
|
-
ctx.system(
|
36
|
-
"npm", "--userconfig", "./.npmrc", "config", "set", "engine-strict", "true"
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
def extension_point_version
|
41
|
-
if extension_point.sdks.assemblyscript.versioned?
|
42
|
-
return extension_point.sdks.assemblyscript.version
|
43
|
-
end
|
44
|
-
|
45
|
-
out, status = ctx.capture2e("npm show #{extension_point.sdks.assemblyscript.package} version --json")
|
46
|
-
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
47
|
-
"^#{JSON.parse(out)}"
|
48
|
-
end
|
49
|
-
|
50
|
-
def write_package_json
|
51
|
-
package_json = <<~HERE
|
52
|
-
{
|
53
|
-
"name": "#{script_name}",
|
54
|
-
"version": "1.0.0",
|
55
|
-
"devDependencies": {
|
56
|
-
"@shopify/scripts-sdk-as": "#{extension_point.sdks.assemblyscript.sdk_version}",
|
57
|
-
"@shopify/scripts-toolchain-as": "#{extension_point.sdks.assemblyscript.toolchain_version}",
|
58
|
-
"#{extension_point.sdks.assemblyscript.package}": "#{extension_point_version}",
|
59
|
-
"@as-pect/cli": "^6.0.0",
|
60
|
-
"assemblyscript": "^0.18.13"
|
61
|
-
},
|
62
|
-
"scripts": {
|
63
|
-
"test": "asp --summary --verbose",
|
64
|
-
"build": "#{build_command}"
|
65
|
-
},
|
66
|
-
"engines": {
|
67
|
-
"node": ">=#{MIN_NODE_VERSION}"
|
68
|
-
}
|
69
|
-
}
|
70
|
-
HERE
|
71
|
-
ctx.write("package.json", package_json)
|
72
|
-
end
|
73
|
-
|
74
|
-
def bootstap_command
|
75
|
-
type = extension_point.dasherize_type
|
76
|
-
base_command = format(BOOTSTRAP, extension_point: type, base: path_to_project)
|
77
|
-
domain = extension_point.domain
|
78
|
-
|
79
|
-
if domain.nil?
|
80
|
-
base_command
|
81
|
-
else
|
82
|
-
"#{base_command} --domain #{domain}"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def build_command
|
87
|
-
type = extension_point.dasherize_type
|
88
|
-
base_command = format(BUILD, script_name: script_name)
|
89
|
-
domain = extension_point.domain
|
90
|
-
|
91
|
-
if domain.nil?
|
92
|
-
"#{base_command} #{ASC_ARGS}"
|
93
|
-
else
|
94
|
-
"#{base_command} --domain #{domain} --ep #{type} #{ASC_ARGS}"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|