shopify-cli 2.11.2 → 2.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/CODEOWNERS +5 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +1 -1
- data/.github/workflows/shopify.yml +2 -1
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +44 -1
- data/Gemfile.lock +18 -18
- data/Rakefile +16 -0
- data/bin/shopify +12 -8
- data/dev.yml +1 -1
- data/docs/users/installation.md +1 -44
- data/ext/javy/hashes/javy-arm-macos-v0.2.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-arm-macos-v0.2.1.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-linux-v0.2.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-linux-v0.2.1.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-macos-v0.2.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-macos-v0.2.1.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-windows-v0.2.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-windows-v0.2.1.gz.sha256 +1 -0
- data/ext/javy/version +1 -1
- data/lib/project_types/extension/features/argo_setup_steps.rb +4 -6
- data/lib/project_types/extension/models/npm_package.rb +19 -1
- data/lib/project_types/extension/models/server_config/development_renderer.rb +4 -3
- data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +114 -0
- data/lib/project_types/extension/tasks/configure_features.rb +15 -2
- data/lib/project_types/extension/tasks/convert_server_config.rb +2 -1
- data/lib/project_types/script/cli.rb +2 -4
- data/lib/project_types/script/commands/create.rb +5 -5
- data/lib/project_types/script/commands/push.rb +4 -6
- data/lib/project_types/script/config/extension_points.yml +0 -10
- data/lib/project_types/script/errors.rb +1 -1
- data/lib/project_types/script/forms/create.rb +7 -20
- data/lib/project_types/script/layers/application/build_script.rb +9 -26
- data/lib/project_types/script/layers/application/connect_app.rb +3 -2
- data/lib/project_types/script/layers/application/create_script.rb +9 -10
- data/lib/project_types/script/layers/application/project_dependencies.rb +12 -14
- data/lib/project_types/script/layers/application/push_script.rb +14 -10
- data/lib/project_types/script/layers/domain/errors.rb +3 -3
- data/lib/project_types/script/layers/domain/push_package.rb +6 -0
- data/lib/project_types/script/layers/domain/script_config.rb +2 -4
- data/lib/project_types/script/layers/domain/script_project.rb +3 -2
- data/lib/project_types/script/layers/infrastructure/errors.rb +11 -0
- data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +0 -16
- data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +0 -1
- data/lib/project_types/script/layers/infrastructure/languages/tool_version_checker.rb +26 -0
- data/lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb +22 -10
- data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +32 -29
- data/lib/project_types/script/layers/infrastructure/languages/wasm_project_creator.rb +0 -3
- data/lib/project_types/script/layers/infrastructure/languages/wasm_task_runner.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +3 -21
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +14 -26
- data/lib/project_types/script/layers/infrastructure/script_service.rb +4 -2
- data/lib/project_types/script/loaders/project.rb +8 -7
- data/lib/project_types/script/messages/messages.rb +22 -21
- data/lib/project_types/script/ui/error_handler.rb +17 -4
- data/lib/project_types/script/ui/strict_spinner.rb +4 -6
- data/lib/project_types/theme/cli.rb +2 -0
- data/lib/project_types/theme/commands/common/root_helper.rb +71 -0
- data/lib/project_types/theme/commands/init.rb +2 -0
- data/lib/project_types/theme/commands/list.rb +34 -0
- data/lib/project_types/theme/commands/open.rb +65 -0
- data/lib/project_types/theme/commands/package.rb +1 -0
- data/lib/project_types/theme/commands/pull.rb +18 -10
- data/lib/project_types/theme/commands/push.rb +17 -9
- data/lib/project_types/theme/commands/serve.rb +6 -2
- data/lib/project_types/theme/conversions/base_glob.rb +50 -0
- data/lib/project_types/theme/conversions/ignore_glob.rb +15 -0
- data/lib/project_types/theme/conversions/include_glob.rb +15 -0
- data/lib/project_types/theme/forms/select.rb +11 -39
- data/lib/project_types/theme/messages/messages.rb +38 -7
- data/lib/project_types/theme/presenters/theme_presenter.rb +48 -0
- data/lib/project_types/theme/presenters/themes_presenter.rb +32 -0
- data/lib/shopify_cli/api.rb +1 -1
- data/lib/shopify_cli/commands/app/create/node.rb +1 -0
- data/lib/shopify_cli/commands/app/create/php.rb +1 -0
- data/lib/shopify_cli/commands/app/create/rails.rb +1 -0
- data/lib/shopify_cli/commands/app/deploy.rb +1 -1
- data/lib/shopify_cli/constants.rb +2 -2
- data/lib/shopify_cli/context.rb +13 -15
- data/lib/shopify_cli/core/entry_point.rb +1 -1
- data/lib/shopify_cli/core/monorail.rb +14 -6
- data/lib/shopify_cli/environment.rb +6 -0
- data/lib/shopify_cli/exception_reporter.rb +2 -0
- data/lib/shopify_cli/git.rb +9 -1
- data/lib/shopify_cli/messages/messages.rb +21 -1
- data/lib/shopify_cli/packager.rb +1 -1
- data/lib/shopify_cli/result.rb +14 -0
- data/lib/shopify_cli/services/app/create/rails_service.rb +1 -1
- data/lib/shopify_cli/tasks/ensure_git_dependency.rb +14 -0
- data/lib/shopify_cli/tasks.rb +1 -0
- data/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb +5 -5
- data/lib/shopify_cli/theme/dev_server/proxy.rb +14 -2
- data/lib/shopify_cli/theme/dev_server/watcher.rb +10 -2
- data/lib/shopify_cli/theme/development_theme.rb +2 -5
- data/lib/shopify_cli/theme/include_filter.rb +4 -2
- data/lib/shopify_cli/theme/syncer.rb +40 -36
- data/lib/shopify_cli/theme/theme.rb +16 -27
- data/lib/shopify_cli/theme/theme_admin_api.rb +71 -0
- data/lib/shopify_cli/transform_data_structure.rb +3 -2
- data/lib/shopify_cli/version.rb +1 -1
- data/shipit.yml +3 -0
- data/shopify-cli.gemspec +9 -2
- data/shopify-dev +9 -11
- metadata +26 -8
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +0 -25
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +0 -98
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module ShopifyCLI
|
|
2
|
+
module Theme
|
|
3
|
+
class ThemeAdminAPI
|
|
4
|
+
API_VERSION = "unstable"
|
|
5
|
+
|
|
6
|
+
attr_reader :shop
|
|
7
|
+
|
|
8
|
+
def initialize(ctx, shop = nil)
|
|
9
|
+
@ctx = ctx
|
|
10
|
+
@shop = shop || get_shop_or_abort
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get(path:, **args)
|
|
14
|
+
rest_request(
|
|
15
|
+
method: "GET",
|
|
16
|
+
path: path,
|
|
17
|
+
**args
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def put(path:, **args)
|
|
22
|
+
rest_request(
|
|
23
|
+
method: "PUT",
|
|
24
|
+
path: path,
|
|
25
|
+
**args
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def post(path:, **args)
|
|
30
|
+
rest_request(
|
|
31
|
+
method: "POST",
|
|
32
|
+
path: path,
|
|
33
|
+
**args
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def delete(path:, **args)
|
|
38
|
+
rest_request(
|
|
39
|
+
method: "DELETE",
|
|
40
|
+
path: path,
|
|
41
|
+
**args
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def get_shop_or_abort # rubocop:disable Naming/AccessorMethodName
|
|
46
|
+
ShopifyCLI::AdminAPI.get_shop_or_abort(@ctx)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def rest_request(**args)
|
|
52
|
+
ShopifyCLI::AdminAPI.rest_request(
|
|
53
|
+
@ctx,
|
|
54
|
+
shop: @shop,
|
|
55
|
+
api_version: API_VERSION,
|
|
56
|
+
**args.compact
|
|
57
|
+
)
|
|
58
|
+
rescue ShopifyCLI::API::APIRequestForbiddenError,
|
|
59
|
+
ShopifyCLI::API::APIRequestUnauthorizedError
|
|
60
|
+
handle_permissions_error
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def handle_permissions_error
|
|
64
|
+
ensure_user_error = @ctx.message("theme.ensure_user_error", get_shop_or_abort)
|
|
65
|
+
ensure_user_try_this = @ctx.message("theme.ensure_user_try_this")
|
|
66
|
+
|
|
67
|
+
@ctx.abort(ensure_user_error, ensure_user_try_this)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -40,6 +40,7 @@ module ShopifyCLI
|
|
|
40
40
|
|
|
41
41
|
property! :underscore_keys, accepts: [true, false], default: false, reader: :underscore_keys?
|
|
42
42
|
property! :symbolize_keys, accepts: [true, false], default: false, reader: :symbolize_keys?
|
|
43
|
+
property! :shallow, accepts: [true, false], default: false, reader: :shallow?
|
|
43
44
|
property! :associative_array_container,
|
|
44
45
|
accepts: ->(c) { c.respond_to?(:new) && c.method_defined?(:[]=) },
|
|
45
46
|
default: -> { Hash }
|
|
@@ -47,10 +48,10 @@ module ShopifyCLI
|
|
|
47
48
|
def call(object)
|
|
48
49
|
case object
|
|
49
50
|
when Array
|
|
50
|
-
object.map(&self).map(&:value)
|
|
51
|
+
shallow? ? object.dup : object.map(&self).map(&:value)
|
|
51
52
|
when Hash
|
|
52
53
|
object.each.with_object(associative_array_container.new) do |(key, value), result|
|
|
53
|
-
result[transform_key(key)] = call(value).value
|
|
54
|
+
result[transform_key(key)] = shallow? ? value : call(value).value
|
|
54
55
|
end
|
|
55
56
|
else
|
|
56
57
|
ShopifyCLI::Result.success(object)
|
data/lib/shopify_cli/version.rb
CHANGED
data/shipit.yml
ADDED
data/shopify-cli.gemspec
CHANGED
|
@@ -35,11 +35,18 @@ Gem::Specification.new do |spec|
|
|
|
35
35
|
spec.require_paths = ["lib", "vendor"]
|
|
36
36
|
spec.executables << "shopify"
|
|
37
37
|
|
|
38
|
-
spec.add_development_dependency("bundler", "~> 2.
|
|
38
|
+
spec.add_development_dependency("bundler", "~> 2.3.8")
|
|
39
39
|
spec.add_development_dependency("rake", "~> 12.3", ">= 12.3.3")
|
|
40
40
|
spec.add_development_dependency("minitest", "~> 5.0")
|
|
41
41
|
|
|
42
42
|
spec.add_dependency("bugsnag", "~> 6.22")
|
|
43
43
|
spec.add_dependency("listen", "~> 3.7.0")
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
# We prefer being more strict here with the version range to have a more deterministic build.
|
|
46
|
+
# The added benefit is that, if the user upgrades the CLI, and we have "~> 1.10.1" version range,
|
|
47
|
+
# they will get a theme-check update.
|
|
48
|
+
# Whereas if we were to have "~> 1.9", that version would still be satisfied and thus not upgraded.
|
|
49
|
+
# Both shopify-cli and theme-check gems are owned and developed by Shopify.
|
|
50
|
+
# These gems are currently being actively developed and it's easiest to update them together.
|
|
51
|
+
spec.add_dependency("theme-check", "~> 1.10.1")
|
|
45
52
|
end
|
data/shopify-dev
CHANGED
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
require_relative "./bin/load_shopify"
|
|
4
4
|
|
|
5
5
|
exit(proc do
|
|
6
|
-
|
|
7
|
-
ShopifyCLI::
|
|
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
|
|
6
|
+
ShopifyCLI::ErrorHandler.call do
|
|
7
|
+
ShopifyCLI::Core::EntryPoint.call(ARGV.dup)
|
|
17
8
|
end
|
|
9
|
+
rescue StandardError => error
|
|
10
|
+
ShopifyCLI::ErrorHandler.exception = error
|
|
11
|
+
if ShopifyCLI::Environment.print_stacktrace?
|
|
12
|
+
raise error
|
|
13
|
+
else
|
|
14
|
+
1
|
|
15
|
+
end
|
|
18
16
|
end.call)
|
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: 2.
|
|
4
|
+
version: 2.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shopify
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-03-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 2.
|
|
19
|
+
version: 2.3.8
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 2.
|
|
26
|
+
version: 2.3.8
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -92,14 +92,14 @@ dependencies:
|
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 1.
|
|
95
|
+
version: 1.10.1
|
|
96
96
|
type: :runtime
|
|
97
97
|
prerelease: false
|
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
|
100
100
|
- - "~>"
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: 1.
|
|
102
|
+
version: 1.10.1
|
|
103
103
|
description: |
|
|
104
104
|
Shopify CLI helps you build Shopify apps faster. It quickly scaffolds Node.js
|
|
105
105
|
and Ruby on Rails embedded apps. It also automates many common tasks in the
|
|
@@ -154,9 +154,17 @@ files:
|
|
|
154
154
|
- docs/users/installation.md
|
|
155
155
|
- docs/users/migrate-from-themekit.md
|
|
156
156
|
- ext/javy/hashes/javy-arm-macos-v0.1.0.gz.sha256
|
|
157
|
+
- ext/javy/hashes/javy-arm-macos-v0.2.0.gz.sha256
|
|
158
|
+
- ext/javy/hashes/javy-arm-macos-v0.2.1.gz.sha256
|
|
157
159
|
- ext/javy/hashes/javy-x86_64-linux-v0.1.0.gz.sha256
|
|
160
|
+
- ext/javy/hashes/javy-x86_64-linux-v0.2.0.gz.sha256
|
|
161
|
+
- ext/javy/hashes/javy-x86_64-linux-v0.2.1.gz.sha256
|
|
158
162
|
- ext/javy/hashes/javy-x86_64-macos-v0.1.0.gz.sha256
|
|
163
|
+
- ext/javy/hashes/javy-x86_64-macos-v0.2.0.gz.sha256
|
|
164
|
+
- ext/javy/hashes/javy-x86_64-macos-v0.2.1.gz.sha256
|
|
159
165
|
- ext/javy/hashes/javy-x86_64-windows-v0.1.0.gz.sha256
|
|
166
|
+
- ext/javy/hashes/javy-x86_64-windows-v0.2.0.gz.sha256
|
|
167
|
+
- ext/javy/hashes/javy-x86_64-windows-v0.2.1.gz.sha256
|
|
160
168
|
- ext/javy/javy.rb
|
|
161
169
|
- ext/javy/version
|
|
162
170
|
- ext/shopify-extensions/extconf.rb
|
|
@@ -313,10 +321,9 @@ files:
|
|
|
313
321
|
- lib/project_types/script/layers/infrastructure/command_runner.rb
|
|
314
322
|
- lib/project_types/script/layers/infrastructure/errors.rb
|
|
315
323
|
- lib/project_types/script/layers/infrastructure/extension_point_repository.rb
|
|
316
|
-
- lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb
|
|
317
|
-
- lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb
|
|
318
324
|
- lib/project_types/script/layers/infrastructure/languages/project_creator.rb
|
|
319
325
|
- lib/project_types/script/layers/infrastructure/languages/task_runner.rb
|
|
326
|
+
- lib/project_types/script/layers/infrastructure/languages/tool_version_checker.rb
|
|
320
327
|
- lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb
|
|
321
328
|
- lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb
|
|
322
329
|
- lib/project_types/script/layers/infrastructure/languages/wasm_project_creator.rb
|
|
@@ -335,17 +342,25 @@ files:
|
|
|
335
342
|
- lib/project_types/script/ui/strict_spinner.rb
|
|
336
343
|
- lib/project_types/theme/cli.rb
|
|
337
344
|
- lib/project_types/theme/commands/check.rb
|
|
345
|
+
- lib/project_types/theme/commands/common/root_helper.rb
|
|
338
346
|
- lib/project_types/theme/commands/delete.rb
|
|
339
347
|
- lib/project_types/theme/commands/init.rb
|
|
340
348
|
- lib/project_types/theme/commands/language_server.rb
|
|
349
|
+
- lib/project_types/theme/commands/list.rb
|
|
350
|
+
- lib/project_types/theme/commands/open.rb
|
|
341
351
|
- lib/project_types/theme/commands/package.rb
|
|
342
352
|
- lib/project_types/theme/commands/publish.rb
|
|
343
353
|
- lib/project_types/theme/commands/pull.rb
|
|
344
354
|
- lib/project_types/theme/commands/push.rb
|
|
345
355
|
- lib/project_types/theme/commands/serve.rb
|
|
356
|
+
- lib/project_types/theme/conversions/base_glob.rb
|
|
357
|
+
- lib/project_types/theme/conversions/ignore_glob.rb
|
|
358
|
+
- lib/project_types/theme/conversions/include_glob.rb
|
|
346
359
|
- lib/project_types/theme/forms/confirm_store.rb
|
|
347
360
|
- lib/project_types/theme/forms/select.rb
|
|
348
361
|
- lib/project_types/theme/messages/messages.rb
|
|
362
|
+
- lib/project_types/theme/presenters/theme_presenter.rb
|
|
363
|
+
- lib/project_types/theme/presenters/themes_presenter.rb
|
|
349
364
|
- lib/project_types/theme/ui/sync_progress_bar.rb
|
|
350
365
|
- lib/rubygems_plugin.rb
|
|
351
366
|
- lib/shopify_cli.rb
|
|
@@ -459,6 +474,7 @@ files:
|
|
|
459
474
|
- lib/shopify_cli/tasks/ensure_authenticated.rb
|
|
460
475
|
- lib/shopify_cli/tasks/ensure_dev_store.rb
|
|
461
476
|
- lib/shopify_cli/tasks/ensure_env.rb
|
|
477
|
+
- lib/shopify_cli/tasks/ensure_git_dependency.rb
|
|
462
478
|
- lib/shopify_cli/tasks/ensure_loopback_url.rb
|
|
463
479
|
- lib/shopify_cli/tasks/ensure_project_type.rb
|
|
464
480
|
- lib/shopify_cli/tasks/select_org_and_shop.rb
|
|
@@ -488,12 +504,14 @@ files:
|
|
|
488
504
|
- lib/shopify_cli/theme/syncer/operation.rb
|
|
489
505
|
- lib/shopify_cli/theme/syncer/standard_reporter.rb
|
|
490
506
|
- lib/shopify_cli/theme/theme.rb
|
|
507
|
+
- lib/shopify_cli/theme/theme_admin_api.rb
|
|
491
508
|
- lib/shopify_cli/thread_pool.rb
|
|
492
509
|
- lib/shopify_cli/thread_pool/job.rb
|
|
493
510
|
- lib/shopify_cli/transform_data_structure.rb
|
|
494
511
|
- lib/shopify_cli/tunnel.rb
|
|
495
512
|
- lib/shopify_cli/utilities.rb
|
|
496
513
|
- lib/shopify_cli/version.rb
|
|
514
|
+
- shipit.yml
|
|
497
515
|
- shopify-cli.gemspec
|
|
498
516
|
- shopify-dev
|
|
499
517
|
- utilities/constants.rb
|
data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Script
|
|
4
|
-
module Layers
|
|
5
|
-
module Infrastructure
|
|
6
|
-
module Languages
|
|
7
|
-
class AssemblyScriptProjectCreator < ProjectCreator
|
|
8
|
-
MIN_NODE_VERSION = "14.5.0" # kept because task_runner uses this
|
|
9
|
-
NPM_SET_REGISTRY_COMMAND = "npm --userconfig ./.npmrc config set @shopify:registry https://registry.npmjs.com"
|
|
10
|
-
NPM_SET_ENGINE_STRICT_COMMAND = "npm --userconfig ./.npmrc config set engine-strict true"
|
|
11
|
-
|
|
12
|
-
def self.config_file
|
|
13
|
-
"package.json"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def setup_dependencies
|
|
17
|
-
super
|
|
18
|
-
command_runner.call(NPM_SET_REGISTRY_COMMAND)
|
|
19
|
-
command_runner.call(NPM_SET_ENGINE_STRICT_COMMAND)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Script
|
|
4
|
-
module Layers
|
|
5
|
-
module Infrastructure
|
|
6
|
-
module Languages
|
|
7
|
-
class AssemblyScriptTaskRunner < TaskRunner
|
|
8
|
-
BYTECODE_FILE = "build/script.wasm"
|
|
9
|
-
METADATA_FILE = "build/metadata.json"
|
|
10
|
-
SCRIPT_SDK_BUILD = "npm run build"
|
|
11
|
-
|
|
12
|
-
def build
|
|
13
|
-
compile
|
|
14
|
-
bytecode
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def install_dependencies
|
|
18
|
-
check_node_version!
|
|
19
|
-
|
|
20
|
-
output, status = ctx.capture2e("npm install --no-audit --no-optional --legacy-peer-deps --loglevel error")
|
|
21
|
-
raise Errors::DependencyInstallError, output unless status.success?
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def dependencies_installed?
|
|
25
|
-
# Assuming if node_modules folder exist at root of script folder, all deps are installed
|
|
26
|
-
ctx.dir_exist?("node_modules")
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def metadata_file_location
|
|
30
|
-
METADATA_FILE
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def library_version(library_name)
|
|
34
|
-
output = JSON.parse(CommandRunner.new(ctx: ctx).call("npm -s list --json"))
|
|
35
|
-
library_version_from_npm_list(output, library_name)
|
|
36
|
-
rescue Errors::SystemCallFailureError => error
|
|
37
|
-
library_version_from_npm_list_error_output(error, library_name)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
private
|
|
41
|
-
|
|
42
|
-
def library_version_from_npm_list_error_output(error, library_name)
|
|
43
|
-
# npm list can return a failure status code, even when returning the correct data.
|
|
44
|
-
# This causes the CommandRunner to throw a SystemCallFailure error that contains the data.
|
|
45
|
-
# In here, we check that the output contains `npm list`'s structure and extract the version.
|
|
46
|
-
output = JSON.parse(error.out)
|
|
47
|
-
raise error unless output.key?("dependencies")
|
|
48
|
-
|
|
49
|
-
library_version_from_npm_list(output, library_name)
|
|
50
|
-
rescue JSON::ParserError
|
|
51
|
-
raise error
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def library_version_from_npm_list(output, library_name)
|
|
55
|
-
output.dig("dependencies", library_name, "version").tap do |version|
|
|
56
|
-
raise Errors::APILibraryNotFoundError, library_name unless version
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def check_node_version!
|
|
61
|
-
output, status = @ctx.capture2e("node", "--version")
|
|
62
|
-
raise Errors::DependencyInstallError, output unless status.success?
|
|
63
|
-
|
|
64
|
-
require "semantic/semantic"
|
|
65
|
-
version = ::Semantic::Version.new(output[1..-1])
|
|
66
|
-
unless version >= ::Semantic::Version.new(AssemblyScriptProjectCreator::MIN_NODE_VERSION)
|
|
67
|
-
raise Errors::DependencyInstallError,
|
|
68
|
-
"Node version must be >= v#{AssemblyScriptProjectCreator::MIN_NODE_VERSION}. "\
|
|
69
|
-
"Current version: #{output.strip}."
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def compile
|
|
74
|
-
check_compilation_dependencies!
|
|
75
|
-
CommandRunner.new(ctx: ctx).call(SCRIPT_SDK_BUILD)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def check_compilation_dependencies!
|
|
79
|
-
pkg = JSON.parse(File.read("package.json"))
|
|
80
|
-
build_script = pkg.dig("scripts", "build")
|
|
81
|
-
|
|
82
|
-
raise Errors::BuildScriptNotFoundError,
|
|
83
|
-
"Build script not found" if build_script.nil?
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def bytecode
|
|
87
|
-
raise Errors::WebAssemblyBinaryNotFoundError unless ctx.file_exist?(BYTECODE_FILE)
|
|
88
|
-
|
|
89
|
-
contents = ctx.binread(BYTECODE_FILE)
|
|
90
|
-
ctx.rm(BYTECODE_FILE)
|
|
91
|
-
|
|
92
|
-
contents
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|