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
@@ -52,8 +52,8 @@ module ShopifyCli
|
|
52
52
|
# invokes the original `call` implementation and wraps its return value
|
53
53
|
# into a result object.
|
54
54
|
#
|
55
|
-
def call(*args, **kwargs)
|
56
|
-
Result.wrap { super(*args, **kwargs) }.call
|
55
|
+
def call(*args, **kwargs, &block)
|
56
|
+
Result.wrap { kwargs.any? ? super(*args, **kwargs, &block) : super(*args, &block) }.call
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -64,10 +64,10 @@ module ShopifyCli
|
|
64
64
|
# initializer or to `call`. If the keyword argument matches the name of
|
65
65
|
# property, it is forwarded to the initializer, otherwise to call.
|
66
66
|
#
|
67
|
-
def call(*args, **kwargs)
|
67
|
+
def call(*args, **kwargs, &block)
|
68
68
|
properties.keys.yield_self do |properties|
|
69
69
|
new(**kwargs.slice(*properties))
|
70
|
-
.call(*args, **kwargs.slice(*(kwargs.keys - properties)))
|
70
|
+
.call(*args, **kwargs.slice(*(kwargs.keys - properties)), &block)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
data/lib/shopify-cli/oauth.rb
CHANGED
@@ -80,7 +80,13 @@ module ShopifyCli
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def output_authentication_info(uri)
|
83
|
-
login_location =
|
83
|
+
login_location = if service == "admin"
|
84
|
+
ctx.message("core.oauth.location.admin")
|
85
|
+
elsif Shopifolk.acting_as_shopify_organization?
|
86
|
+
ctx.message("core.oauth.location.shopifolk")
|
87
|
+
else
|
88
|
+
ctx.message("core.oauth.location.partner")
|
89
|
+
end
|
84
90
|
ctx.puts(ctx.message("core.oauth.authentication_required", login_location))
|
85
91
|
ctx.open_url!(uri)
|
86
92
|
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
|
@@ -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]
|
@@ -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"]))
|
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"
|
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.1
|
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-14 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,47 +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
|
-
ARGO_POST_PURCHASE = "@shopify/argo-post-purchase"
|
9
|
-
|
10
|
-
PACKAGE_NAMES = [
|
11
|
-
ARGO_CHECKOUT,
|
12
|
-
ARGO_ADMIN,
|
13
|
-
ARGO_POST_PURCHASE
|
14
|
-
].freeze
|
15
|
-
MINIMUM_ARGO_VERSION = "0.9.3".freeze
|
16
|
-
|
17
|
-
property! :package_name, accepts: PACKAGE_NAMES
|
18
|
-
property! :version, accepts: String
|
19
|
-
|
20
|
-
class << self
|
21
|
-
def from_package_manager(package_manager_output)
|
22
|
-
pattern = /(?<name>#{PACKAGE_NAMES.join("|")})@(?<version>\d.*)$/
|
23
|
-
match = package_manager_output.match(pattern)
|
24
|
-
raise PackageNotFound, package_manager_output if match.nil?
|
25
|
-
return new(package_name: match[:name], version: match[:version].strip)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def checkout?
|
30
|
-
package_name == ARGO_CHECKOUT
|
31
|
-
end
|
32
|
-
|
33
|
-
def admin?
|
34
|
-
package_name == ARGO_ADMIN
|
35
|
-
end
|
36
|
-
|
37
|
-
##
|
38
|
-
# Temporarily returns false in all cases as the argo webpack server is
|
39
|
-
# unable to handle the UUID flag.
|
40
|
-
def supports_uuid_flag?
|
41
|
-
return false
|
42
|
-
# return false if checkout?
|
43
|
-
# Gem::Version.new(version) > Gem::Version.new(MINIMUM_ARGO_VERSION)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
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
|