shopify-cli 2.7.1 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +2 -2
  3. data/.github/workflows/shopify.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +43 -0
  7. data/Codespace.dockerfile +2 -2
  8. data/Gemfile.lock +4 -4
  9. data/Tests.dockerfile +2 -2
  10. data/dev.yml +3 -3
  11. data/ext/javy/hashes/javy-arm-macos-v0.1.0.gz.sha256 +1 -0
  12. data/ext/javy/hashes/javy-x86_64-linux-v0.1.0.gz.sha256 +1 -0
  13. data/ext/javy/hashes/javy-x86_64-macos-v0.1.0.gz.sha256 +1 -0
  14. data/ext/javy/hashes/javy-x86_64-windows-v0.1.0.gz.sha256 +1 -0
  15. data/ext/javy/javy.rb +30 -12
  16. data/lib/graphql/get_extension_registrations.graphql +27 -0
  17. data/lib/project_types/extension/cli.rb +27 -2
  18. data/lib/project_types/extension/commands/build.rb +10 -15
  19. data/lib/project_types/extension/commands/create.rb +3 -6
  20. data/lib/project_types/extension/commands/push.rb +36 -8
  21. data/lib/project_types/extension/extension_project.rb +1 -1
  22. data/lib/project_types/extension/features/argo_serve.rb +6 -5
  23. data/lib/project_types/extension/forms/questions/ask_registration.rb +6 -2
  24. data/lib/project_types/extension/loaders/project.rb +29 -0
  25. data/lib/project_types/extension/loaders/specification_handler.rb +22 -0
  26. data/lib/project_types/extension/messages/messages.rb +4 -2
  27. data/lib/project_types/extension/models/app.rb +1 -1
  28. data/lib/project_types/extension/models/development_server.rb +2 -2
  29. data/lib/project_types/extension/models/specification_handlers/default.rb +4 -0
  30. data/lib/project_types/extension/tasks/convert_server_config.rb +3 -1
  31. data/lib/project_types/extension/tasks/execute_commands/base.rb +13 -0
  32. data/lib/project_types/extension/tasks/execute_commands/build.rb +29 -0
  33. data/lib/project_types/extension/tasks/execute_commands/create.rb +33 -0
  34. data/lib/project_types/extension/tasks/execute_commands/serve.rb +35 -0
  35. data/lib/project_types/extension/tasks/merge_server_config.rb +33 -22
  36. data/lib/project_types/rails/commands/create.rb +2 -4
  37. data/lib/project_types/script/cli.rb +8 -1
  38. data/lib/project_types/script/commands/connect.rb +19 -0
  39. data/lib/project_types/script/commands/create.rb +1 -3
  40. data/lib/project_types/script/commands/javy.rb +0 -2
  41. data/lib/project_types/script/commands/push.rb +2 -1
  42. data/lib/project_types/script/config/extension_points.yml +10 -28
  43. data/lib/project_types/script/forms/ask_app.rb +32 -0
  44. data/lib/project_types/script/forms/ask_org.rb +30 -0
  45. data/lib/project_types/script/forms/ask_script_uuid.rb +22 -0
  46. data/lib/project_types/script/forms/run_against_shopify_org.rb +14 -0
  47. data/lib/project_types/script/graphql/app_script_set.graphql +2 -2
  48. data/lib/project_types/script/layers/application/build_script.rb +0 -1
  49. data/lib/project_types/script/layers/application/connect_app.rb +79 -0
  50. data/lib/project_types/script/layers/application/create_script.rb +17 -17
  51. data/lib/project_types/script/layers/application/push_script.rb +1 -1
  52. data/lib/project_types/script/layers/domain/errors.rb +1 -4
  53. data/lib/project_types/script/layers/domain/push_package.rb +3 -3
  54. data/lib/project_types/script/layers/domain/{script_json.rb → script_config.rb} +2 -2
  55. data/lib/project_types/script/layers/domain/script_project.rb +5 -1
  56. data/lib/project_types/script/layers/infrastructure/errors.rb +28 -6
  57. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +0 -4
  58. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +0 -4
  59. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +2 -2
  60. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +125 -27
  61. data/lib/project_types/script/layers/infrastructure/script_service.rb +11 -11
  62. data/lib/project_types/script/messages/messages.rb +20 -5
  63. data/lib/project_types/script/ui/error_handler.rb +30 -20
  64. data/lib/project_types/theme/commands/pull.rb +3 -0
  65. data/lib/project_types/theme/commands/push.rb +7 -1
  66. data/lib/project_types/theme/commands/serve.rb +1 -1
  67. data/lib/project_types/theme/messages/messages.rb +10 -0
  68. data/lib/project_types/theme/ui/sync_progress_bar.rb +2 -2
  69. data/lib/shopify_cli/command/project_command.rb +20 -7
  70. data/lib/shopify_cli/command.rb +6 -0
  71. data/lib/shopify_cli/commands/app/create/node.rb +1 -3
  72. data/lib/shopify_cli/commands/app/create/rails.rb +1 -3
  73. data/lib/shopify_cli/commands/login.rb +1 -1
  74. data/lib/shopify_cli/commands/switch.rb +1 -1
  75. data/lib/shopify_cli/constants.rb +7 -0
  76. data/lib/shopify_cli/context.rb +11 -1
  77. data/lib/shopify_cli/environment.rb +4 -0
  78. data/lib/shopify_cli/form.rb +2 -0
  79. data/lib/shopify_cli/git.rb +2 -0
  80. data/lib/shopify_cli/identity_auth.rb +18 -0
  81. data/lib/shopify_cli/messages/messages.rb +8 -1
  82. data/lib/shopify_cli/partners_api/app_extensions/job.rb +36 -0
  83. data/lib/shopify_cli/partners_api/app_extensions.rb +46 -0
  84. data/lib/shopify_cli/partners_api/organizations.rb +2 -5
  85. data/lib/shopify_cli/partners_api.rb +2 -8
  86. data/lib/shopify_cli/project.rb +8 -7
  87. data/lib/shopify_cli/resources/env_file.rb +13 -5
  88. data/lib/shopify_cli/services/app/create/rails_service.rb +1 -1
  89. data/lib/shopify_cli/services/app/serve/node_service.rb +1 -1
  90. data/lib/shopify_cli/services/app/serve/rails_service.rb +1 -1
  91. data/lib/shopify_cli/tasks/ensure_authenticated.rb +9 -3
  92. data/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +73 -0
  93. data/lib/shopify_cli/theme/dev_server/hot-reload.js +38 -9
  94. data/lib/shopify_cli/theme/dev_server/proxy/template_param_builder.rb +84 -0
  95. data/lib/shopify_cli/theme/dev_server/proxy.rb +9 -15
  96. data/lib/shopify_cli/theme/dev_server.rb +6 -4
  97. data/lib/shopify_cli/theme/syncer/error_reporter.rb +45 -0
  98. data/lib/shopify_cli/theme/syncer/operation.rb +56 -0
  99. data/lib/shopify_cli/theme/syncer/standard_reporter.rb +32 -0
  100. data/lib/shopify_cli/theme/syncer.rb +40 -39
  101. data/lib/shopify_cli/theme/theme.rb +31 -19
  102. data/lib/shopify_cli/thread_pool/job.rb +27 -0
  103. data/lib/shopify_cli/thread_pool.rb +37 -0
  104. data/lib/shopify_cli/tunnel.rb +9 -10
  105. data/lib/shopify_cli/version.rb +1 -1
  106. data/shopify-cli.gemspec +1 -1
  107. data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +3 -1
  108. metadata +31 -8
  109. data/lib/graphql/all_orgs_with_extensions.graphql +0 -37
  110. data/lib/project_types/extension/tasks/run_extension_command.rb +0 -82
  111. data/lib/project_types/script/tasks/ensure_env.rb +0 -106
@@ -43,7 +43,7 @@ module Script
43
43
  extension_point_type: package.extension_point_type,
44
44
  force: force,
45
45
  metadata: package.metadata,
46
- script_json: package.script_json,
46
+ script_config: package.script_config,
47
47
  module_upload_url: module_upload_url,
48
48
  library: package.library,
49
49
  )
@@ -14,7 +14,7 @@ module Script
14
14
  end
15
15
  end
16
16
 
17
- class MissingScriptJsonFieldError < ScriptProjectError
17
+ class MissingScriptConfigFieldError < ScriptProjectError
18
18
  attr_reader :field
19
19
  def initialize(field)
20
20
  super()
@@ -22,9 +22,6 @@ module Script
22
22
  end
23
23
  end
24
24
 
25
- class InvalidScriptJsonDefinitionError < ScriptProjectError; end
26
- class NoScriptJsonFile < ScriptProjectError; end
27
-
28
25
  class ScriptNotFoundError < ScriptProjectError
29
26
  attr_reader :script_name, :extension_point_type
30
27
  def initialize(extension_point_type, script_name)
@@ -7,7 +7,7 @@ module Script
7
7
  attr_reader :id,
8
8
  :uuid,
9
9
  :extension_point_type,
10
- :script_json,
10
+ :script_config,
11
11
  :script_content,
12
12
  :compiled_type,
13
13
  :metadata,
@@ -20,7 +20,7 @@ module Script
20
20
  script_content:,
21
21
  compiled_type: nil,
22
22
  metadata:,
23
- script_json:,
23
+ script_config:,
24
24
  library:
25
25
  )
26
26
  @id = id
@@ -29,7 +29,7 @@ module Script
29
29
  @script_content = script_content
30
30
  @compiled_type = compiled_type
31
31
  @metadata = metadata
32
- @script_json = script_json
32
+ @script_config = script_config
33
33
  @library = library
34
34
  end
35
35
  end
@@ -3,7 +3,7 @@
3
3
  module Script
4
4
  module Layers
5
5
  module Domain
6
- class ScriptJson
6
+ class ScriptConfig
7
7
  attr_reader :content, :version, :title, :description, :configuration_ui, :configuration
8
8
 
9
9
  REQUIRED_FIELDS = %w(version title)
@@ -23,7 +23,7 @@ module Script
23
23
 
24
24
  def validate_content!(content)
25
25
  REQUIRED_FIELDS.each do |field|
26
- raise Errors::MissingScriptJsonFieldError, field if content[field].nil?
26
+ raise Errors::MissingScriptConfigFieldError, field if content[field].nil?
27
27
  end
28
28
  end
29
29
  end
@@ -15,7 +15,7 @@ module Script
15
15
  property! :script_name, accepts: String
16
16
  property! :language, accepts: String
17
17
 
18
- property :script_json, accepts: ScriptJson
18
+ property :script_config, accepts: ScriptConfig
19
19
 
20
20
  def initialize(*)
21
21
  super
@@ -43,6 +43,10 @@ module Script
43
43
  !raw_uuid.nil?
44
44
  end
45
45
 
46
+ def env_valid?
47
+ api_key && api_secret && uuid_defined?
48
+ end
49
+
46
50
  private
47
51
 
48
52
  def raw_uuid
@@ -5,9 +5,9 @@ module Script
5
5
  module Infrastructure
6
6
  module Errors
7
7
  class BuildError < ScriptProjectError; end
8
- class ScriptJsonSyntaxError < ScriptProjectError; end
8
+ class ScriptConfigSyntaxError < ScriptProjectError; end
9
9
 
10
- class ScriptJsonMissingKeysError < ScriptProjectError
10
+ class ScriptConfigMissingKeysError < ScriptProjectError
11
11
  attr_reader :missing_keys
12
12
  def initialize(missing_keys)
13
13
  super()
@@ -15,7 +15,7 @@ module Script
15
15
  end
16
16
  end
17
17
 
18
- class ScriptJsonInvalidValueError < ScriptProjectError
18
+ class ScriptConfigInvalidValueError < ScriptProjectError
19
19
  attr_reader :valid_input_modes
20
20
  def initialize(valid_input_modes)
21
21
  super()
@@ -23,7 +23,7 @@ module Script
23
23
  end
24
24
  end
25
25
 
26
- class ScriptJsonFieldsMissingKeysError < ScriptProjectError
26
+ class ScriptConfigFieldsMissingKeysError < ScriptProjectError
27
27
  attr_reader :missing_keys
28
28
  def initialize(missing_keys)
29
29
  super()
@@ -31,7 +31,7 @@ module Script
31
31
  end
32
32
  end
33
33
 
34
- class ScriptJsonFieldsInvalidValueError < ScriptProjectError
34
+ class ScriptConfigFieldsInvalidValueError < ScriptProjectError
35
35
  attr_reader :valid_types
36
36
  def initialize(valid_types)
37
37
  super()
@@ -39,6 +39,29 @@ module Script
39
39
  end
40
40
  end
41
41
 
42
+ class InvalidScriptConfigYmlDefinitionError < ScriptProjectError; end
43
+
44
+ class InvalidScriptJsonDefinitionError < ScriptProjectError; end
45
+
46
+ class MissingScriptConfigYmlFieldError < ScriptProjectError
47
+ attr_reader :field
48
+ def initialize(field)
49
+ super()
50
+ @field = field
51
+ end
52
+ end
53
+
54
+ class MissingScriptJsonFieldError < ScriptProjectError
55
+ attr_reader :field
56
+ def initialize(field)
57
+ super()
58
+ @field = field
59
+ end
60
+ end
61
+
62
+ class NoScriptConfigYmlFileError < ScriptProjectError; end
63
+ class NoScriptConfigFileError < ScriptProjectError; end
64
+
42
65
  class APILibraryNotFoundError < ScriptProjectError
43
66
  attr_reader :library_name
44
67
  def initialize(library_name)
@@ -109,7 +132,6 @@ module Script
109
132
  class ScriptProjectAlreadyExistsError < ScriptProjectError; end
110
133
  class TaskRunnerNotFoundError < ScriptProjectError; end
111
134
  class BuildScriptNotFoundError < ScriptProjectError; end
112
- class InvalidBuildScriptError < ScriptProjectError; end
113
135
 
114
136
  class WebAssemblyBinaryNotFoundError < ScriptProjectError
115
137
  def initialize
@@ -98,10 +98,6 @@ module Script
98
98
 
99
99
  raise Errors::BuildScriptNotFoundError,
100
100
  "Build script not found" if build_script.nil?
101
-
102
- unless build_script.start_with?("shopify-scripts")
103
- raise Errors::InvalidBuildScriptError, "Invalid build script"
104
- end
105
101
  end
106
102
 
107
103
  def bytecode
@@ -100,10 +100,6 @@ module Script
100
100
 
101
101
  raise Errors::BuildScriptNotFoundError,
102
102
  "Build script not found" if build_script.nil?
103
-
104
- unless build_script.start_with?("javy")
105
- raise Errors::InvalidBuildScriptError, "Invalid build script"
106
- end
107
103
  end
108
104
 
109
105
  def bytecode
@@ -18,7 +18,7 @@ module Script
18
18
  script_content: script_content,
19
19
  compiled_type: compiled_type,
20
20
  metadata: metadata,
21
- script_json: script_project.script_json,
21
+ script_config: script_project.script_config,
22
22
  library: library
23
23
  )
24
24
  end
@@ -34,7 +34,7 @@ module Script
34
34
  extension_point_type: script_project.extension_point_type,
35
35
  script_content: script_content,
36
36
  metadata: metadata,
37
- script_json: script_project.script_json,
37
+ script_config: script_project.script_config,
38
38
  library: library
39
39
  )
40
40
  end
@@ -6,10 +6,26 @@ module Script
6
6
  class ScriptProjectRepository
7
7
  include SmartProperties
8
8
  property! :ctx, accepts: ShopifyCLI::Context
9
+ property :directory, accepts: String
10
+ property :initial_directory, accepts: String
9
11
 
10
- SCRIPT_JSON_FILENAME = "script.json"
11
12
  MUTABLE_ENV_VALUES = %i(uuid)
12
13
 
14
+ def create_project_directory
15
+ raise Infrastructure::Errors::ScriptProjectAlreadyExistsError, directory if ctx.dir_exist?(directory)
16
+ ctx.mkdir_p(directory)
17
+ change_directory(directory: directory)
18
+ end
19
+
20
+ def delete_project_directory
21
+ change_to_initial_directory
22
+ ctx.rm_r(directory)
23
+ end
24
+
25
+ def change_to_initial_directory
26
+ change_directory(directory: initial_directory)
27
+ end
28
+
13
29
  def create(script_name:, extension_point_type:, language:)
14
30
  validate_metadata!(extension_point_type, language)
15
31
 
@@ -40,7 +56,7 @@ module Script
40
56
  script_name: script_name,
41
57
  extension_point_type: extension_point_type,
42
58
  language: language,
43
- script_json: ScriptJsonRepository.new(ctx: ctx).get
59
+ script_config: script_config_repository.get!
44
60
  )
45
61
  end
46
62
 
@@ -58,7 +74,7 @@ module Script
58
74
  script_name: script_name,
59
75
  extension_point_type: extension_point_type,
60
76
  language: language,
61
- script_json: ScriptJsonRepository.new(ctx: ctx).get,
77
+ script_config: script_config_repository.get!,
62
78
  )
63
79
  end
64
80
 
@@ -77,14 +93,12 @@ module Script
77
93
  script_name: script_name,
78
94
  extension_point_type: extension_point_type,
79
95
  language: language,
80
- script_json: ScriptJsonRepository.new(ctx: ctx).get,
96
+ script_config: script_config_repository.get!,
81
97
  )
82
98
  end
83
99
 
84
- def update_or_create_script_json(title:)
85
- script_json = ScriptJsonRepository
86
- .new(ctx: ctx)
87
- .update_or_create(title: title)
100
+ def update_script_config(title:)
101
+ script_config = script_config_repository.update!(title: title)
88
102
 
89
103
  Domain::ScriptProject.new(
90
104
  id: ctx.root,
@@ -92,12 +106,16 @@ module Script
92
106
  script_name: script_name,
93
107
  extension_point_type: extension_point_type,
94
108
  language: language,
95
- script_json: script_json,
109
+ script_config: script_config,
96
110
  )
97
111
  end
98
112
 
99
113
  private
100
114
 
115
+ def change_directory(directory:)
116
+ ctx.chdir(directory)
117
+ end
118
+
101
119
  def capture_io(&block)
102
120
  CLI::UI::StdoutRouter::Capture.new(&block).run
103
121
  end
@@ -140,40 +158,120 @@ module Script
140
158
  end
141
159
  end
142
160
 
143
- class ScriptJsonRepository
161
+ def script_config_repository
162
+ @script_config_repository ||= begin
163
+ supported_repos = [
164
+ ScriptConfigYmlRepository.new(ctx: ctx),
165
+ ScriptJsonRepository.new(ctx: ctx),
166
+ ]
167
+ repo = supported_repos.find(&:active?)
168
+ raise Infrastructure::Errors::NoScriptConfigYmlFileError if repo.nil?
169
+ repo
170
+ end
171
+ end
172
+
173
+ class ScriptConfigRepository
144
174
  include SmartProperties
145
175
  property! :ctx, accepts: ShopifyCLI::Context
146
176
 
147
- def get
148
- current_script_json || raise(Domain::Errors::NoScriptJsonFile)
177
+ def active?
178
+ ctx.file_exist?(filename)
179
+ end
180
+
181
+ def get!
182
+ raise Infrastructure::Errors::NoScriptConfigFileError unless active?
183
+
184
+ content = ctx.read(filename)
185
+ hash = file_content_to_hash(content)
186
+
187
+ from_h(hash)
188
+ end
189
+
190
+ def update!(title:)
191
+ hash = get!.content
192
+ update_hash(hash: hash, title: title)
193
+
194
+ ctx.write(filename, hash_to_file_content(hash))
195
+
196
+ from_h(hash)
197
+ end
198
+
199
+ private
200
+
201
+ def update_hash(hash:, title:)
202
+ hash["version"] ||= "2"
203
+ hash["title"] = title
204
+ end
205
+
206
+ def from_h(hash)
207
+ Domain::ScriptConfig.new(content: hash)
208
+ rescue Domain::Errors::MissingScriptConfigFieldError => e
209
+ raise missing_field_error, e.field
149
210
  end
150
211
 
151
- def update_or_create(title:)
152
- json = current_script_json&.content || {}
153
- json["version"] ||= "1"
154
- json["title"] = title
212
+ # to be implemented by subclasses
213
+ def filename
214
+ raise NotImplementedError
215
+ end
155
216
 
156
- ctx.write(SCRIPT_JSON_FILENAME, JSON.pretty_generate(json))
217
+ def file_content_to_hash(file_content)
218
+ raise NotImplementedError
219
+ end
157
220
 
158
- Domain::ScriptJson.new(content: json)
221
+ def hash_to_file_content(hash)
222
+ raise NotImplementedError
159
223
  end
160
224
 
225
+ def missing_field_error
226
+ raise NotImplementedError
227
+ end
228
+ end
229
+
230
+ class ScriptConfigYmlRepository < ScriptConfigRepository
161
231
  private
162
232
 
163
- def current_script_json
164
- return nil unless ctx.file_exist?(SCRIPT_JSON_FILENAME)
233
+ def filename
234
+ "script.config.yml"
235
+ end
236
+
237
+ def file_content_to_hash(file_content)
238
+ begin
239
+ hash = YAML.load(file_content)
240
+ rescue Psych::SyntaxError
241
+ raise Errors::InvalidScriptConfigYmlDefinitionError
242
+ end
243
+ raise Errors::InvalidScriptConfigYmlDefinitionError unless hash.is_a?(Hash)
244
+ hash
245
+ end
246
+
247
+ def hash_to_file_content(hash)
248
+ YAML.dump(hash)
249
+ end
165
250
 
166
- content = ctx.read(SCRIPT_JSON_FILENAME)
167
- raise Domain::Errors::InvalidScriptJsonDefinitionError unless valid_script_json?(content)
251
+ def missing_field_error
252
+ Errors::MissingScriptConfigYmlFieldError
253
+ end
254
+ end
168
255
 
169
- Domain::ScriptJson.new(content: JSON.parse(content))
256
+ class ScriptJsonRepository < ScriptConfigRepository
257
+ private
258
+
259
+ def filename
260
+ "script.json"
170
261
  end
171
262
 
172
- def valid_script_json?(content)
173
- JSON.parse(content)
174
- true
263
+ def file_content_to_hash(file_content)
264
+ JSON.parse(file_content)
175
265
  rescue JSON::ParserError
176
- false
266
+ raise Errors::InvalidScriptJsonDefinitionError
267
+ end
268
+
269
+ def hash_to_file_content(hash)
270
+ JSON.pretty_generate(hash)
271
+ end
272
+
273
+ def missing_field_error
274
+ Errors::MissingScriptJsonFieldError
177
275
  end
178
276
  end
179
277
  end
@@ -17,7 +17,7 @@ module Script
17
17
  extension_point_type:,
18
18
  force: false,
19
19
  metadata:,
20
- script_json:,
20
+ script_config:,
21
21
  module_upload_url:,
22
22
  library:
23
23
  )
@@ -25,14 +25,14 @@ module Script
25
25
  variables = {
26
26
  uuid: uuid,
27
27
  extensionPointName: extension_point_type.upcase,
28
- title: script_json.title,
29
- description: script_json.description,
28
+ title: script_config.title,
29
+ description: script_config.description,
30
30
  force: force,
31
31
  schemaMajorVersion: metadata.schema_major_version.to_s, # API expects string value
32
32
  schemaMinorVersion: metadata.schema_minor_version.to_s, # API expects string value
33
- scriptJsonVersion: script_json.version,
34
- configurationUi: script_json.configuration_ui,
35
- configurationDefinition: script_json.configuration&.to_json,
33
+ scriptConfigVersion: script_config.version,
34
+ configurationUi: script_config.configuration_ui,
35
+ configurationDefinition: script_config.configuration&.to_json,
36
36
  moduleUploadUrl: module_upload_url,
37
37
  library: {
38
38
  language: library[:language],
@@ -47,19 +47,19 @@ module Script
47
47
  if user_errors.any? { |e| e["tag"] == "already_exists_error" }
48
48
  raise Errors::ScriptRepushError, uuid
49
49
  elsif (e = user_errors.any? { |err| err["tag"] == "configuration_definition_syntax_error" })
50
- raise Errors::ScriptJsonSyntaxError
50
+ raise Errors::ScriptConfigSyntaxError
51
51
  elsif (e = user_errors.find { |err| err["tag"] == "configuration_definition_missing_keys_error" })
52
- raise Errors::ScriptJsonMissingKeysError, e["message"]
52
+ raise Errors::ScriptConfigMissingKeysError, e["message"]
53
53
  elsif (e = user_errors.find { |err| err["tag"] == "configuration_definition_invalid_value_error" })
54
- raise Errors::ScriptJsonInvalidValueError, e["message"]
54
+ raise Errors::ScriptConfigInvalidValueError, e["message"]
55
55
  elsif (e = user_errors.find do |err|
56
56
  err["tag"] == "configuration_definition_schema_field_missing_keys_error"
57
57
  end)
58
- raise Errors::ScriptJsonFieldsMissingKeysError, e["message"]
58
+ raise Errors::ScriptConfigFieldsMissingKeysError, e["message"]
59
59
  elsif (e = user_errors.find do |err|
60
60
  err["tag"] == "configuration_definition_schema_field_invalid_value_error"
61
61
  end)
62
- raise Errors::ScriptJsonFieldsInvalidValueError, e["message"]
62
+ raise Errors::ScriptConfigFieldsInvalidValueError, e["message"]
63
63
  elsif user_errors.find { |err| %w(not_use_msgpack_error schema_version_argument_error).include?(err["tag"]) }
64
64
  raise Domain::Errors::MetadataValidationError
65
65
  else
@@ -47,14 +47,20 @@ module Script
47
47
  invalid_language_cause: "Invalid language %s.",
48
48
  invalid_language_help: "Allowed values: %s.",
49
49
 
50
+ missing_script_config_yml_field_cause: "The script.config.yml file is missing the required %s field.",
51
+ missing_script_config_yml_field_help: "Add the field and try again.",
52
+
50
53
  missing_script_json_field_cause: "The script.json file is missing the required %s field.",
51
54
  missing_script_json_field_help: "Add the field and try again.",
52
55
 
53
56
  invalid_script_json_definition_cause: "The script.json file contains invalid JSON.",
54
57
  invalid_script_json_definition_help: "Fix the errors and try again.",
55
58
 
56
- no_script_json_file_cause: "The script.json file is missing.",
57
- no_script_json_file_help: "Create this file and try again.",
59
+ invalid_script_config_yml_definition_cause: "The script.config.yml file contains invalid YAML.",
60
+ invalid_script_config_yml_definition_help: "Fix the errors and try again.",
61
+
62
+ no_script_config_yml_file_cause: "The script.config.yml file is missing.",
63
+ no_script_config_yml_file_help: "Create this file and try again.",
58
64
 
59
65
  configuration_syntax_error_cause: "The script.json is not formatted properly.",
60
66
  configuration_syntax_error_help: "Fix the errors and try again.",
@@ -115,8 +121,6 @@ module Script
115
121
  script_repush_cause: "A version of this script already exists on the app.",
116
122
  script_repush_help: "Use {{cyan:--force}} to replace the existing script.",
117
123
 
118
- invalid_build_script: "The root package.json contains an invalid build command that " \
119
- "is needed to compile your script to WebAssembly.",
120
124
  build_script_not_found: "The root package.json is missing the build command that " \
121
125
  "is needed to compile your script to WebAssembly.",
122
126
  # rubocop:disable Layout/LineLength
@@ -140,6 +144,7 @@ module Script
140
144
 
141
145
  language_library_for_api_not_found_cause: "Script can’t be pushed because the %{language} library for API %{api} is missing.",
142
146
  language_library_for_api_not_found_help: "Make sure extension_point.yml contains the correct API library.",
147
+ no_scripts_found_in_app: "The selected apps have no scripts. Please, create them first on the partners' dashboard.",
143
148
  },
144
149
 
145
150
  create: {
@@ -175,7 +180,17 @@ module Script
175
180
 
176
181
  script_pushed: "{{v}} Script pushed to app (API key: %{api_key}).",
177
182
  },
178
-
183
+ connect: {
184
+ connected: "Connected! Your project is now connected to {{green:%s}}",
185
+ missing_script: "No script has been selected.",
186
+ help: <<~HELP,
187
+ {{command:%s script connect}}: Connects an existing script to an app.
188
+ Usage: {{command:%s script connect}}
189
+ HELP
190
+ error: {
191
+ operation_failed: "Couldn't connect script to app.",
192
+ },
193
+ },
179
194
  javy: {
180
195
  help: <<~HELP,
181
196
  Compile the JavaScript code into WebAssembly.
@@ -103,32 +103,47 @@ module Script
103
103
  cause_of_error: ShopifyCLI::Context.message("script.error.metadata_not_found_cause"),
104
104
  help_suggestion: ShopifyCLI::Context.message("script.error.metadata_not_found_help"),
105
105
  }
106
- when Layers::Domain::Errors::MissingScriptJsonFieldError
106
+ when Layers::Infrastructure::Errors::BuildError
107
107
  {
108
- cause_of_error: ShopifyCLI::Context.message("script.error.missing_script_json_field_cause", e.field),
109
- help_suggestion: ShopifyCLI::Context.message("script.error.missing_script_json_field_help"),
108
+ cause_of_error: ShopifyCLI::Context.message("script.error.build_error_cause"),
109
+ help_suggestion: ShopifyCLI::Context.message("script.error.build_error_help"),
110
110
  }
111
- when Layers::Domain::Errors::InvalidScriptJsonDefinitionError
111
+ when Layers::Infrastructure::Errors::InvalidScriptConfigYmlDefinitionError
112
+ {
113
+ cause_of_error: ShopifyCLI::Context.message("script.error.invalid_script_config_yml_definition_cause"),
114
+ help_suggestion: ShopifyCLI::Context.message("script.error.invalid_script_config_yml_definition_help"),
115
+ }
116
+ when Layers::Infrastructure::Errors::InvalidScriptJsonDefinitionError
112
117
  {
113
118
  cause_of_error: ShopifyCLI::Context.message("script.error.invalid_script_json_definition_cause"),
114
119
  help_suggestion: ShopifyCLI::Context.message("script.error.invalid_script_json_definition_help"),
115
120
  }
116
- when Layers::Domain::Errors::NoScriptJsonFile
121
+ when Layers::Infrastructure::Errors::MissingScriptConfigYmlFieldError
117
122
  {
118
- cause_of_error: ShopifyCLI::Context.message("script.error.no_script_json_file_cause"),
119
- help_suggestion: ShopifyCLI::Context.message("script.error.no_script_json_file_help"),
123
+ cause_of_error: ShopifyCLI::Context.message("script.error.missing_script_config_yml_field_cause", e.field),
124
+ help_suggestion: ShopifyCLI::Context.message("script.error.missing_script_config_yml_field_help"),
120
125
  }
121
- when Layers::Infrastructure::Errors::BuildError
126
+ when Layers::Infrastructure::Errors::MissingScriptConfigYmlFieldError
122
127
  {
123
- cause_of_error: ShopifyCLI::Context.message("script.error.build_error_cause"),
124
- help_suggestion: ShopifyCLI::Context.message("script.error.build_error_help"),
128
+ cause_of_error: ShopifyCLI::Context.message("script.error.missing_script_config_yml_field_cause", e.field),
129
+ help_suggestion: ShopifyCLI::Context.message("script.error.missing_script_config_yml_field_help"),
125
130
  }
126
- when Layers::Infrastructure::Errors::ScriptJsonSyntaxError
131
+ when Layers::Infrastructure::Errors::MissingScriptJsonFieldError
132
+ {
133
+ cause_of_error: ShopifyCLI::Context.message("script.error.missing_script_json_field_cause", e.field),
134
+ help_suggestion: ShopifyCLI::Context.message("script.error.missing_script_json_field_help"),
135
+ }
136
+ when Layers::Infrastructure::Errors::NoScriptConfigYmlFileError
137
+ {
138
+ cause_of_error: ShopifyCLI::Context.message("script.error.no_script_config_yml_file_cause"),
139
+ help_suggestion: ShopifyCLI::Context.message("script.error.no_script_config_yml_file_help"),
140
+ }
141
+ when Layers::Infrastructure::Errors::ScriptConfigSyntaxError
127
142
  {
128
143
  cause_of_error: ShopifyCLI::Context.message("script.error.configuration_syntax_error_cause"),
129
144
  help_suggestion: ShopifyCLI::Context.message("script.error.configuration_syntax_error_help"),
130
145
  }
131
- when Layers::Infrastructure::Errors::ScriptJsonMissingKeysError
146
+ when Layers::Infrastructure::Errors::ScriptConfigMissingKeysError
132
147
  {
133
148
  cause_of_error: ShopifyCLI::Context.message(
134
149
  "script.error.configuration_missing_keys_error_cause",
@@ -136,7 +151,7 @@ module Script
136
151
  ),
137
152
  help_suggestion: ShopifyCLI::Context.message("script.error.configuration_missing_keys_error_help"),
138
153
  }
139
- when Layers::Infrastructure::Errors::ScriptJsonInvalidValueError
154
+ when Layers::Infrastructure::Errors::ScriptConfigInvalidValueError
140
155
  {
141
156
  cause_of_error: ShopifyCLI::Context.message(
142
157
  "script.error.configuration_invalid_value_error_cause",
@@ -144,7 +159,7 @@ module Script
144
159
  ),
145
160
  help_suggestion: ShopifyCLI::Context.message("script.error.configuration_invalid_value_error_help"),
146
161
  }
147
- when Layers::Infrastructure::Errors::ScriptJsonFieldsMissingKeysError
162
+ when Layers::Infrastructure::Errors::ScriptConfigFieldsMissingKeysError
148
163
  {
149
164
  cause_of_error: ShopifyCLI::Context.message(
150
165
  "script.error.configuration_schema_field_missing_keys_error_cause",
@@ -154,7 +169,7 @@ module Script
154
169
  "script.error.configuration_definition_schema_field_missing_keys_error_help"
155
170
  ),
156
171
  }
157
- when Layers::Infrastructure::Errors::ScriptJsonFieldsInvalidValueError
172
+ when Layers::Infrastructure::Errors::ScriptConfigFieldsInvalidValueError
158
173
  {
159
174
  cause_of_error: ShopifyCLI::Context.message(
160
175
  "script.error.configuration_schema_field_invalid_value_error_cause",
@@ -201,11 +216,6 @@ module Script
201
216
  cause_of_error: ShopifyCLI::Context.message("script.error.build_script_not_found"),
202
217
  help_suggestion: ShopifyCLI::Context.message("script.error.build_script_suggestion"),
203
218
  }
204
- when Layers::Infrastructure::Errors::InvalidBuildScriptError
205
- {
206
- cause_of_error: ShopifyCLI::Context.message("script.error.invalid_build_script"),
207
- help_suggestion: ShopifyCLI::Context.message("script.error.build_script_suggestion"),
208
- }
209
219
  when Layers::Infrastructure::Errors::WebAssemblyBinaryNotFoundError
210
220
  {
211
221
  cause_of_error: ShopifyCLI::Context.message("script.error.web_assembly_binary_not_found"),
@@ -9,6 +9,7 @@ module Theme
9
9
  options do |parser, flags|
10
10
  parser.on("-n", "--nodelete") { flags[:nodelete] = true }
11
11
  parser.on("-i", "--themeid=ID") { |theme_id| flags[:theme_id] = theme_id }
12
+ parser.on("-l", "--live") { flags[:live] = true }
12
13
  parser.on("-x", "--ignore=PATTERN") do |pattern|
13
14
  flags[:ignores] ||= []
14
15
  flags[:ignores] << pattern
@@ -21,6 +22,8 @@ module Theme
21
22
 
22
23
  theme = if (theme_id = options.flags[:theme_id])
23
24
  ShopifyCLI::Theme::Theme.new(@ctx, root: root, id: theme_id)
25
+ elsif options.flags[:live]
26
+ ShopifyCLI::Theme::Theme.live(@ctx, root: root)
24
27
  else
25
28
  form = Forms::Select.ask(
26
29
  @ctx,