shopify-cli 2.9.0 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.yaml +117 -0
  3. data/.github/ISSUE_TEMPLATE/enhancement.yaml +38 -0
  4. data/.github/ISSUE_TEMPLATE/feature.yaml +47 -0
  5. data/.github/ISSUE_TEMPLATE.md +18 -0
  6. data/CHANGELOG.md +38 -5
  7. data/Gemfile.lock +1 -1
  8. data/dev.yml +3 -0
  9. data/lib/project_types/extension/commands/build.rb +3 -0
  10. data/lib/project_types/extension/commands/check.rb +3 -0
  11. data/lib/project_types/extension/commands/create.rb +3 -0
  12. data/lib/project_types/extension/commands/push.rb +3 -0
  13. data/lib/project_types/extension/commands/serve.rb +3 -0
  14. data/lib/project_types/extension/models/specification_handlers/default.rb +1 -1
  15. data/lib/project_types/extension/tasks/convert_server_config.rb +3 -1
  16. data/lib/project_types/script/cli.rb +5 -0
  17. data/lib/project_types/script/commands/connect.rb +3 -1
  18. data/lib/project_types/script/commands/create.rb +2 -0
  19. data/lib/project_types/script/commands/push.rb +6 -0
  20. data/lib/project_types/script/config/extension_points.yml +12 -0
  21. data/lib/project_types/script/graphql/app_script_set.graphql +2 -0
  22. data/lib/project_types/script/graphql/module_upload_url_generate.graphql +5 -1
  23. data/lib/project_types/script/layers/application/build_script.rb +6 -3
  24. data/lib/project_types/script/layers/application/project_dependencies.rb +1 -1
  25. data/lib/project_types/script/layers/application/push_script.rb +38 -30
  26. data/lib/project_types/script/layers/domain/errors.rb +10 -3
  27. data/lib/project_types/script/layers/domain/extension_point.rb +2 -2
  28. data/lib/project_types/script/layers/domain/push_package.rb +0 -3
  29. data/lib/project_types/script/layers/domain/script_config.rb +6 -4
  30. data/lib/project_types/script/layers/domain/script_project.rb +1 -0
  31. data/lib/project_types/script/layers/infrastructure/errors.rb +47 -24
  32. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +2 -12
  33. data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +1 -0
  34. data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +1 -0
  35. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +2 -12
  36. data/lib/project_types/script/layers/infrastructure/languages/wasm_project_creator.rb +15 -0
  37. data/lib/project_types/script/layers/infrastructure/languages/wasm_task_runner.rb +36 -0
  38. data/lib/project_types/script/layers/infrastructure/metadata_repository.rb +18 -0
  39. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +7 -8
  40. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +45 -54
  41. data/lib/project_types/script/layers/infrastructure/script_service.rb +35 -12
  42. data/lib/project_types/script/layers/infrastructure/script_uploader.rb +22 -9
  43. data/lib/project_types/script/loaders/project.rb +2 -1
  44. data/lib/project_types/script/messages/messages.rb +94 -88
  45. data/lib/project_types/script/ui/error_handler.rb +75 -38
  46. data/lib/project_types/theme/commands/check.rb +3 -0
  47. data/lib/project_types/theme/commands/delete.rb +3 -0
  48. data/lib/project_types/theme/commands/init.rb +3 -0
  49. data/lib/project_types/theme/commands/language_server.rb +3 -0
  50. data/lib/project_types/theme/commands/package.rb +3 -0
  51. data/lib/project_types/theme/commands/publish.rb +3 -0
  52. data/lib/project_types/theme/commands/pull.rb +12 -1
  53. data/lib/project_types/theme/commands/push.rb +12 -1
  54. data/lib/project_types/theme/commands/serve.rb +3 -0
  55. data/lib/project_types/theme/messages/messages.rb +4 -0
  56. data/lib/shopify_cli/command/sub_command.rb +2 -0
  57. data/lib/shopify_cli/command.rb +66 -0
  58. data/lib/shopify_cli/commands/app/create/node.rb +3 -0
  59. data/lib/shopify_cli/commands/app/create/rails.rb +3 -0
  60. data/lib/shopify_cli/commands/app/create.rb +3 -0
  61. data/lib/shopify_cli/commands/app/deploy.rb +3 -0
  62. data/lib/shopify_cli/commands/app/serve.rb +3 -0
  63. data/lib/shopify_cli/commands/login.rb +4 -10
  64. data/lib/shopify_cli/constants.rb +18 -2
  65. data/lib/shopify_cli/core/executor.rb +4 -4
  66. data/lib/shopify_cli/environment.rb +61 -16
  67. data/lib/shopify_cli/exception_reporter.rb +9 -0
  68. data/lib/shopify_cli/github/issue_url_generator.rb +19 -8
  69. data/lib/shopify_cli/identity_auth/env_auth_token.rb +34 -0
  70. data/lib/shopify_cli/identity_auth.rb +36 -18
  71. data/lib/shopify_cli/messages/messages.rb +2 -2
  72. data/lib/shopify_cli/method_object.rb +21 -9
  73. data/lib/shopify_cli/partners_api.rb +7 -2
  74. data/lib/shopify_cli/result.rb +61 -59
  75. data/lib/shopify_cli/services/app/create/rails_service.rb +37 -13
  76. data/lib/shopify_cli/task.rb +5 -3
  77. data/lib/shopify_cli/theme/file.rb +2 -2
  78. data/lib/shopify_cli/theme/filter/path_matcher.rb +38 -0
  79. data/lib/shopify_cli/theme/ignore_filter.rb +14 -18
  80. data/lib/shopify_cli/theme/include_filter.rb +65 -0
  81. data/lib/shopify_cli/theme/syncer.rb +17 -2
  82. data/lib/shopify_cli/utilities.rb +7 -0
  83. data/lib/shopify_cli/version.rb +1 -1
  84. data/lib/shopify_cli.rb +3 -1
  85. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +11 -6
  86. data/vendor/deps/cli-kit/lib/cli/kit/util.rb +5 -1
  87. data/vendor/deps/cli-ui/lib/cli/ui/os.rb +6 -4
  88. data/vendor/deps/ruby2_keywords/LICENSE +22 -0
  89. data/vendor/deps/ruby2_keywords/README.md +67 -0
  90. data/vendor/deps/ruby2_keywords/Rakefile +54 -0
  91. data/vendor/deps/ruby2_keywords/lib/ruby2_keywords.rb +57 -0
  92. data/vendor/deps/ruby2_keywords/ruby2_keywords.gemspec +18 -0
  93. data/vendor/deps/ruby2_keywords/test/test_keyword.rb +41 -0
  94. data/vendor/lib/semantic/version.rb +0 -1
  95. metadata +18 -3
  96. data/lib/project_types/rails/commands/create.rb +0 -210
@@ -5,90 +5,91 @@ module Script
5
5
  MESSAGES = {
6
6
  script: {
7
7
  help: <<~HELP,
8
- Suite of commands for developing script applications. See {{command:%1$s script <command> --help}} for usage of each command.
8
+ Suite of commands for developing script applications. Run {{command:%1$s script <command> --help}} for usage of each command.
9
9
  Usage: {{command:%1$s script [ %2$s ]}}
10
10
  HELP
11
11
 
12
12
  error: {
13
- deprecated_ep: "This project uses a Script API (%s) that has been deprecated. "\
14
- "This Script won't work in production.",
15
- deprecated_ep_cause: "Try using a different Script API.",
13
+ deprecated_ep: "This script won't run in a store because "\
14
+ "it uses a deprecated Script API (%s).",
15
+ deprecated_ep_cause: "Recreate this script using a supported Script API.",
16
16
  generic: "{{red:{{x}} Error}}",
17
17
  eacces_cause: "You don't have permission to write to this directory.",
18
- eacces_help: "Try again and choose a different directory.",
18
+ eacces_help: "Get permission for this directory or choose a different one.",
19
19
 
20
20
  enospc_cause: "You don't have enough disk space to do this action.",
21
- enospc_help: "Free up some space and try again.",
21
+ enospc_help: "Free up more space.",
22
22
 
23
23
  oauth_cause: "Something went wrong while authenticating your account with the Partner Dashboard.",
24
- oauth_help: "Try again.",
24
+ oauth_help: "Wait a few minutes and try again.",
25
25
 
26
- invalid_context_cause: "Your .shopify-cli.yml file is not correct. Values are missing for "\
26
+ invalid_context_cause: "Your .shopify-cli.yml is formatted incorrectly. It's missing values for "\
27
27
  "extension_point_type or script_name.",
28
- invalid_context_help: "Add these values and try again.",
28
+ invalid_context_help: "Add these values.",
29
29
 
30
- invalid_script_name_cause: "Invalid script name.",
31
- invalid_script_name_help: "Replace or remove unsupported characters. Valid characters "\
32
- "are numbers, letters, hyphens, or underscores.",
30
+ invalid_script_name_cause: "Script name contains unsupported characters.",
31
+ invalid_script_name_help: "Use only numbers, letters, hyphens, or underscores.",
33
32
 
34
- no_existing_apps_cause: "You don't have any apps in your Partner Dashboard.",
35
- no_existing_apps_help: "Create an app with {{command:shopify [node|rails] create}}" \
36
- " or visit https://partners.shopify.com/.",
33
+ no_existing_apps_cause: "Your script can't be pushed to an app because your Partner account "\
34
+ "doesn't have any apps.",
35
+ no_existing_apps_help: "Create an app.",
37
36
 
38
- no_existing_orgs_cause: "You don't have any partner organizations.",
39
- no_existing_orgs_help: "Visit https://partners.shopify.com/ to create a partners account.",
37
+ no_existing_orgs_cause: "Your account doesn't belong to a Partner Organization.",
38
+ no_existing_orgs_help: "Visit https://partners.shopify.com/ to create an account.",
40
39
 
41
40
  project_exists_cause: "A directory with this same name already exists.",
42
- project_exists_help: "Try again and enter a different name for the script.",
41
+ project_exists_help: "Choose a different name for your script.",
43
42
 
44
- invalid_extension_cause: "Invalid Script API %s.",
45
- invalid_extension_help: "Allowed values: %s.",
43
+ invalid_extension_cause: "The name of the Script API is incorrect: %s.",
44
+ invalid_extension_help: "Choose a supported API: %s.",
46
45
 
47
- invalid_language_cause: "Invalid language %s.",
48
- invalid_language_help: "Allowed values: %s.",
46
+ invalid_language_cause: "The language is not supported: %s.",
47
+ invalid_language_help: "Choose a supported language: %s.",
49
48
 
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.",
49
+ missing_script_config_field_cause: "The %{filename} file is missing the required %{field} field.",
50
+ missing_script_config_field_help: "Add the field.",
52
51
 
53
- missing_script_json_field_cause: "The script.json file is missing the required %s field.",
54
- missing_script_json_field_help: "Add the field and try again.",
52
+ script_config_parse_error_cause: "The %{filename} file contains incorrect %{serialization_format}.",
53
+ script_config_parse_error_help: "Correct the errors.",
55
54
 
56
- invalid_script_json_definition_cause: "The script.json file contains invalid JSON.",
57
- invalid_script_json_definition_help: "Fix the errors and try again.",
55
+ no_script_config_file_cause: "The %{filename} file is missing.",
56
+ no_script_config_file_help: "Create this file.",
58
57
 
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.",
58
+ app_not_connected_cause: "The script is not connected to an app.",
59
+ app_not_connected_help: "Run {{command:%{tool_name} script connect}}.",
61
60
 
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.",
61
+ configuration_definition_error_cause: "In %{filename} there is a problem with the "\
62
+ "configuration. %{message}",
63
+ configuration_definition_error_help: "Fix the error.",
64
64
 
65
- app_not_connected_cause: "Script is not connected to an app.",
66
- app_not_connected_help: "Run shopify connect or enter fields for api-key and api-secret.",
65
+ configuration_definition_errors_cause: "In %{filename}, there are %{error_count} problems with "\
66
+ "the configuration:\n%{concatenated_messages}\n",
67
+ configuration_definition_errors_help: "Correct the errors.",
67
68
 
68
- configuration_syntax_error_cause: "The script.json is not formatted properly.",
69
- configuration_syntax_error_help: "Fix the errors and try again.",
69
+ configuration_syntax_error_cause: "The %{filename} is not formatted correctly.",
70
+ configuration_syntax_error_help: "Fix the errors.",
70
71
 
71
- configuration_missing_keys_error_cause: "The script.json file is missing required keys: "\
72
+ configuration_missing_keys_error_cause: "The %{filename} is missing required keys: "\
72
73
  "%{missing_keys}.",
73
- configuration_missing_keys_error_help: "Add the keys and try again.",
74
+ configuration_missing_keys_error_help: "Add the keys.",
74
75
 
75
- configuration_invalid_value_error_cause: "The script.json configuration only accepts "\
76
+ configuration_invalid_value_error_cause: "The %{filename} configuration accepts "\
76
77
  "one of the following types(s): %{valid_input_modes}.",
77
- configuration_invalid_value_error_help: "Change the type and try again.",
78
+ configuration_invalid_value_error_help: "Change the value of the type.",
78
79
 
79
- configuration_schema_field_missing_keys_error_cause: "A configuration entry in the script.json file "\
80
+ configuration_schema_field_missing_keys_error_cause: "A configuration entry in the %{filename} file "\
80
81
  "is missing required keys: %{missing_keys}.",
81
- configuration_definition_schema_field_missing_keys_error_help: "Add the keys and try again.",
82
+ configuration_definition_schema_field_missing_keys_error_help: "Add the keys.",
82
83
 
83
84
  configuration_schema_field_invalid_value_error_cause: "The configuration entries in the "\
84
- "script.json file only accept one of the following "\
85
+ "%{filename} file accept one of the following "\
85
86
  "type(s): %{valid_types}.",
86
- configuration_schema_field_invalid_value_error_help: "Change the types and try again.",
87
+ configuration_schema_field_invalid_value_error_help: "Change the value of the type.",
87
88
 
88
- script_not_found_cause: "Couldn't find a script %s for the Script API %s",
89
+ script_not_found_cause: "Can't find script %s for Script API %s",
89
90
 
90
- system_call_failure_cause: "An error was returned while running {{command:%{cmd}}}.",
91
- system_call_failure_help: "Review the following error and try again.\n{{red:%{out}}}",
91
+ system_call_failure_cause: "Something went wrong while running: {{command:%{cmd}}}.",
92
+ system_call_failure_help: "Correct the error.\n{{red:%{out}}}",
92
93
 
93
94
  metadata_validation_cause: "The Script API metadata is incorrect.",
94
95
  metadata_validation_help: "The 'schemaVersions.major' field contains an unsupported version.",
@@ -102,57 +103,58 @@ module Script
102
103
  metadata_schema_versions_missing_minor: "Invalid Script API metadata:" \
103
104
  " 'schemaVersions' is missing the 'minor' field",
104
105
 
105
- metadata_not_found_cause: "Script version file (%s) cannot be found.",
106
- metadata_not_found_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date and " \
107
- "'package.json' contains a 'scripts/build' entry with a " \
108
- "'--metadata build/metadata.json' argument",
106
+ metadata_not_found_cause: "Can't find the script version file (%{filename}).",
107
+ metadata_not_found_help: "Make sure your project is up-to-date and a script metadata file " \
108
+ "is accessible at %{filename}.",
109
109
 
110
110
  build_error_cause: "Something went wrong while building the script.",
111
- build_error_help: "Correct the errors and try again.",
111
+ build_error_help: "Correct the errors.",
112
112
 
113
113
  dependency_install_cause: "Something went wrong while installing the needed dependencies.",
114
- dependency_install_help: "Correct the errors and try again.",
114
+ dependency_install_help: "Correct the errors.",
115
115
 
116
116
  failed_api_request_cause: "Something went wrong while communicating with Shopify.",
117
117
  failed_api_request_help: "Try again.",
118
118
 
119
- forbidden_error_cause: "You do not have permission to do this action.",
119
+ forbidden_error_cause: "You don't have permission to do this action.",
120
120
 
121
121
  graphql_error_cause: "An error was returned: %s.",
122
- graphql_error_help: "\nReview the error and try again.",
122
+ graphql_error_help: "\nCorrect the error.",
123
123
 
124
- script_repush_cause: "A version of this script already exists on the app.",
124
+ script_repush_cause: "Can’t push the script because a version of this script already exists on the app.",
125
125
  script_repush_help: "Use {{cyan:--force}} to replace the existing script.",
126
126
 
127
127
  build_script_not_found: "The root package.json is missing the build command that " \
128
- "is needed to compile your script to WebAssembly.",
128
+ "is needed to compile your script to Wasm.",
129
129
  # rubocop:disable Layout/LineLength
130
130
  build_script_suggestion: "\n\nFor example, your package.json needs the following command:" \
131
131
  "\nbuild: npx shopify-scripts-toolchain-as build --src src/shopify_main.ts --binary build/<script_name>.wasm --metadata build/metadata.json -- --lib node_modules --optimize --use Date=",
132
132
 
133
- web_assembly_binary_not_found: "WebAssembly binary not found.",
134
- web_assembly_binary_not_found_suggestion: "No WebAssembly binary found." \
135
- "Check that your build npm script outputs the generated binary to the root of the directory." \
136
- "Generated binary should match the script name: <script_name>.wasm",
133
+ web_assembly_binary_not_found: "Wasm binary not found.",
134
+ web_assembly_binary_not_found_suggestion: "Check that there is a valid Wasm binary in the root directory" \
135
+ "Your Wasm binary should match the script name: <script_name>.wasm",
137
136
 
138
137
  project_config_not_found: "Internal error - Script can't be created because the project's config file is missing from the repository.",
139
138
 
140
139
  invalid_project_config: "Internal error - Script can't be created because the project's config file is invalid in the repository.",
141
140
 
142
- script_upload_cause: "Fail to upload script.",
141
+ script_upload_cause: "Something went wrong and your script couldn't be pushed.",
143
142
  script_upload_help: "Try again.",
144
143
 
144
+ script_too_large_cause: "The size of your Wasm binary file is too large.",
145
+ script_too_large_help: "It must be less than %{max_size}.",
146
+
145
147
  api_library_not_found_cause: "Script can't be created because API library %{library_name} is missing from the dependencies",
146
- api_library_not_found_help: "This error can occur because the API library was removed from your system or there is a problem with dependencies in the repository.",
148
+ api_library_not_found_help: "This can occur because the API library was removed from your system or there is a problem with dependencies in the repository.",
147
149
 
148
150
  language_library_for_api_not_found_cause: "Script can’t be pushed because the %{language} library for API %{api} is missing.",
149
151
  language_library_for_api_not_found_help: "Make sure extension_point.yml contains the correct API library.",
150
- no_scripts_found_in_app: "The selected apps have no scripts. Please, create them first on the partners' dashboard.",
152
+ no_scripts_found_in_app: "The selected apps have no scripts. Create them first on the partners' dashboard.",
151
153
  missing_env_file_variables: "The following variables are missing in the .env file: %s."\
152
- " It might happen when the script hasn't been previously connected to an app."\
154
+ " This can occur when the script hasn't been connected to an app."\
153
155
  " To connect the script to an app, run {{command:%s script connect}}",
154
- missing_push_options: "The following options are required: %s."\
155
- " You can obtain them from the .env file generated after connecting the script to an app.",
156
+ missing_push_options: "The following options are missing from .env: %s."\
157
+ " Run {{command:%s script connect}} to connect the script to an app and generate these options.",
156
158
  },
157
159
 
158
160
  create: {
@@ -160,26 +162,29 @@ module Script
160
162
  {{command:%1$s script create}}: Creates a script project.
161
163
  Usage: {{command:%1$s script create}}
162
164
  Options:
163
- {{command:--name=NAME}} Script project name. Use any string.
164
- {{command:--api=TYPE}} Script API name. Allowed values: %2$s.
165
- {{command:--language=LANGUAGE}} Programming language. Allowed values: %3$s.
165
+ {{command:--name=NAME}} Script project name.
166
+ {{command:--api=TYPE}} Script API name. Supported values: %2$s.
167
+ {{command:--language=LANGUAGE}} Programming language. Supported values: %3$s.
166
168
  HELP
167
169
 
168
170
  error: {
169
- operation_failed: "Script not created.",
171
+ operation_failed: "Something went wrong and the script wasn't created.",
170
172
  },
171
173
 
172
- change_directory_notice: "{{*}} Change directories to {{green:%s}} to run script commands",
173
- creating: "Creating script",
174
- created: "Created script",
174
+ change_directory_notice: "{{*}} Change directories to {{green:%s}} to run script commands.",
175
+ creating: "Creating script.",
176
+ created: "Created script.",
177
+ preparing_project: "Preparing script project structure.",
178
+ creating_wasm: "Creating configuration files.",
179
+ created_wasm: "Configuration files created.",
175
180
  },
176
181
 
177
182
  push: {
178
183
  help: <<~HELP,
179
- Build the script, upload it to Shopify, and register it to an app. If you've already pushed the script to this app, then use --force to replace the existing version on the app.
184
+ Build the script, upload it to Shopify, and register it to an app.
180
185
  Usage: {{command:%s script push}}
181
186
  Options:
182
- {{command:[--force]}} Replaces the existing script on the app with this version.
187
+ {{command:[--force]}} Replace the existing script with this version.
183
188
  {{command:[--api-key=API_KEY]}} The API key used to register an app with the script. This can be found on the app page on Partners Dashboard. Overrides the value in the .env file, if present.
184
189
  {{command:[--api-secret=API_SECRET]}} The API secret of the app the script is registered with. Overrides the value in the .env file, if present.
185
190
  {{command:[--uuid=UUID]}} The uuid of the script. Overrides the value in the .env file, if present.
@@ -202,34 +207,34 @@ module Script
202
207
  error: {
203
208
  operation_failed: "Couldn't connect script to app.",
204
209
  missing_env_file_variables: "The following variables are missing in the .env file: %s."\
205
- " To connect the script to an app, either enter the value into the .env file or delete the .env file, then run {{command:%s script connect}}",
210
+ " To connect the script to an app, enter the value into the .env file or delete the .env file, and then run {{command:%s script connect}}",
206
211
  },
207
212
  },
208
213
  javy: {
209
214
  help: <<~HELP,
210
- Compile the JavaScript code into WebAssembly.
215
+ Compile the JavaScript code into Wasm.
211
216
  Usage: {{command:%s script javy}}
212
217
  Options:
213
218
  {{command:--in}} The name of the JavaScript file that will be compiled.
214
- {{command:--out}} The name of the file that the WebAssembly should be written to.
219
+ {{command:--out}} The name of the file that the Wasm should be written to.
215
220
  HELP
216
221
  errors: {
217
- invalid_arguments: "Javy was run with invalid arguments. Run {{command: %s script javy --help}} for more information.",
222
+ invalid_arguments: "Javy was run with invalid arguments. Run {{command: %s script javy --help}}.",
218
223
  },
219
224
  },
220
225
 
221
226
  project_deps: {
222
- none_required: "{{v}} None required",
223
- checking_with_npm: "Checking dependencies with npm",
224
- installing: "Dependencies installing",
225
- installed: "Missing dependencies installed",
227
+ none_required: "{{v}} Dependencies are up to date.",
228
+ checking: "Checking dependencies.",
229
+ installing: "Installing dependencies.",
230
+ installed: "Installed missing dependencies.",
226
231
  },
227
232
 
228
233
  forms: {
229
234
  create: {
230
235
  select_extension_point: "Which Script API do you want to use?",
231
236
  select_language: "Which language do you want to use?",
232
- script_name: "Script name",
237
+ script_name: "What do you want to name your script?",
233
238
  },
234
239
  },
235
240
 
@@ -238,14 +243,15 @@ module Script
238
243
  building_script: "Building script",
239
244
  built: "Built",
240
245
  pushing: "Pushing",
246
+ pushing_script: "Pushing script",
241
247
  pushed: "Pushed",
242
248
  ensure_env: {
243
249
  organization: "Partner organization {{green:%s (%s)}}.",
244
250
  organization_select: "Which partner organization do you want to use?",
245
- app: "Script will be pushed to app {{green:%s}}.",
251
+ app: "Push script to app {{green:%s}}.",
246
252
  app_select: "Which app do you want to push this script to?",
247
- ask_connect_to_existing_script: "The selected app has some scripts. Do you want to replace any of the "\
248
- "existing scripts on the app with this script?",
253
+ ask_connect_to_existing_script: "This app contains scripts. Do you want to replace an "\
254
+ "existing script on the app with this script?",
249
255
  ask_which_script_to_connect_to: "Which script do you want to replace?",
250
256
  },
251
257
  },
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "cli/ui"
2
4
 
3
5
  module Script
@@ -5,9 +7,9 @@ module Script
5
7
  module ErrorHandler
6
8
  def self.display(failed_op:, cause_of_error:, help_suggestion:)
7
9
  $stderr.puts(CLI::UI.fmt(ShopifyCLI::Context.message("script.error.generic")))
8
- full_msg = failed_op ? failed_op.dup : ""
9
- full_msg << " #{cause_of_error}" if cause_of_error
10
- full_msg << " #{help_suggestion}" if help_suggestion
10
+ full_msg = failed_op ? failed_op.dup : String.new
11
+ append_msg(full_msg, cause_of_error) if cause_of_error
12
+ append_msg(full_msg, help_suggestion) if help_suggestion
11
13
  $stderr.puts(CLI::UI.fmt(full_msg.strip))
12
14
  end
13
15
 
@@ -22,6 +24,11 @@ module Script
22
24
  display_and_raise(failed_op: failed_op, **messages)
23
25
  end
24
26
 
27
+ private_class_method def self.append_msg(full_msg, msg_to_append)
28
+ full_msg << " " unless /\s$/.match?(full_msg)
29
+ full_msg << msg_to_append
30
+ end
31
+
25
32
  def self.error_messages(e)
26
33
  case e
27
34
  when Errno::EACCES
@@ -100,59 +107,81 @@ module Script
100
107
  }
101
108
  when Layers::Domain::Errors::MetadataNotFoundError
102
109
  {
103
- cause_of_error: ShopifyCLI::Context.message("script.error.metadata_not_found_cause"),
104
- help_suggestion: ShopifyCLI::Context.message("script.error.metadata_not_found_help"),
110
+ cause_of_error: ShopifyCLI::Context.message("script.error.metadata_not_found_cause", filename: e.filename),
111
+ help_suggestion: ShopifyCLI::Context.message("script.error.metadata_not_found_help", filename: e.filename),
112
+ }
113
+ when Layers::Domain::Errors::MissingScriptConfigFieldError
114
+ {
115
+ cause_of_error: ShopifyCLI::Context.message(
116
+ "script.error.missing_script_config_field_cause",
117
+ field: e.field,
118
+ filename: e.filename,
119
+ ),
120
+ help_suggestion: ShopifyCLI::Context.message("script.error.missing_script_config_field_help"),
105
121
  }
106
122
  when Layers::Infrastructure::Errors::BuildError
107
123
  {
108
124
  cause_of_error: ShopifyCLI::Context.message("script.error.build_error_cause"),
109
125
  help_suggestion: ShopifyCLI::Context.message("script.error.build_error_help"),
110
126
  }
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
117
- {
118
- cause_of_error: ShopifyCLI::Context.message("script.error.invalid_script_json_definition_cause"),
119
- help_suggestion: ShopifyCLI::Context.message("script.error.invalid_script_json_definition_help"),
120
- }
121
- when Layers::Infrastructure::Errors::MissingScriptConfigYmlFieldError
122
- {
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"),
125
- }
126
- when Layers::Infrastructure::Errors::MissingScriptConfigYmlFieldError
127
+ when Layers::Infrastructure::Errors::ScriptConfigParseError
127
128
  {
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"),
130
- }
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"),
129
+ cause_of_error: ShopifyCLI::Context.message(
130
+ "script.error.script_config_parse_error_cause",
131
+ filename: e.filename,
132
+ serialization_format: e.serialization_format,
133
+ ),
134
+ help_suggestion: ShopifyCLI::Context.message("script.error.script_config_parse_error_help"),
135
135
  }
136
- when Layers::Infrastructure::Errors::NoScriptConfigYmlFileError
136
+ when Layers::Infrastructure::Errors::NoScriptConfigFileError
137
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
- }
138
+ cause_of_error: ShopifyCLI::Context.message(
139
+ "script.error.no_script_config_file_cause",
140
+ filename: e.filename,
141
+ ),
142
+ help_suggestion: ShopifyCLI::Context.message("script.error.no_script_config_file_help"),
143
+ }
144
+ when Layers::Infrastructure::Errors::ScriptConfigurationDefinitionError
145
+ if e.messages.count == 1
146
+ {
147
+ cause_of_error: ShopifyCLI::Context.message(
148
+ "script.error.configuration_definition_error_cause",
149
+ message: e.messages.fetch(0),
150
+ filename: e.filename,
151
+ ),
152
+ help_suggestion: ShopifyCLI::Context.message("script.error.configuration_definition_error_help"),
153
+ }
154
+ else
155
+ {
156
+ cause_of_error: ShopifyCLI::Context.message(
157
+ "script.error.configuration_definition_errors_cause",
158
+ concatenated_messages: e.messages.map { |m| "{{x}} #{m}" }.join("\n"),
159
+ filename: e.filename,
160
+ error_count: e.messages.count,
161
+ ),
162
+ help_suggestion: ShopifyCLI::Context.message("script.error.configuration_definition_errors_help"),
163
+ }
164
+ end
141
165
  when Layers::Infrastructure::Errors::ScriptConfigSyntaxError
142
166
  {
143
- cause_of_error: ShopifyCLI::Context.message("script.error.configuration_syntax_error_cause"),
167
+ cause_of_error: ShopifyCLI::Context.message(
168
+ "script.error.configuration_syntax_error_cause",
169
+ filename: e.filename,
170
+ ),
144
171
  help_suggestion: ShopifyCLI::Context.message("script.error.configuration_syntax_error_help"),
145
172
  }
146
173
  when Layers::Infrastructure::Errors::ScriptEnvAppNotConnectedError
147
174
  {
148
175
  cause_of_error: ShopifyCLI::Context.message("script.error.app_not_connected_cause"),
149
- help_suggestion: ShopifyCLI::Context.message("script.error.app_not_connected_help"),
176
+ help_suggestion: ShopifyCLI::Context.message("script.error.app_not_connected_help",
177
+ tool_name: ShopifyCLI::TOOL_NAME),
150
178
  }
151
179
  when Layers::Infrastructure::Errors::ScriptConfigMissingKeysError
152
180
  {
153
181
  cause_of_error: ShopifyCLI::Context.message(
154
182
  "script.error.configuration_missing_keys_error_cause",
155
- missing_keys: e.missing_keys
183
+ missing_keys: e.missing_keys,
184
+ filename: e.filename,
156
185
  ),
157
186
  help_suggestion: ShopifyCLI::Context.message("script.error.configuration_missing_keys_error_help"),
158
187
  }
@@ -160,7 +189,8 @@ module Script
160
189
  {
161
190
  cause_of_error: ShopifyCLI::Context.message(
162
191
  "script.error.configuration_invalid_value_error_cause",
163
- valid_input_modes: e.valid_input_modes
192
+ valid_input_modes: e.valid_input_modes,
193
+ filename: e.filename,
164
194
  ),
165
195
  help_suggestion: ShopifyCLI::Context.message("script.error.configuration_invalid_value_error_help"),
166
196
  }
@@ -168,7 +198,8 @@ module Script
168
198
  {
169
199
  cause_of_error: ShopifyCLI::Context.message(
170
200
  "script.error.configuration_schema_field_missing_keys_error_cause",
171
- missing_keys: e.missing_keys
201
+ missing_keys: e.missing_keys,
202
+ filename: e.filename,
172
203
  ),
173
204
  help_suggestion: ShopifyCLI::Context.message(
174
205
  "script.error.configuration_definition_schema_field_missing_keys_error_help"
@@ -178,7 +209,8 @@ module Script
178
209
  {
179
210
  cause_of_error: ShopifyCLI::Context.message(
180
211
  "script.error.configuration_schema_field_invalid_value_error_cause",
181
- valid_types: e.valid_types
212
+ valid_types: e.valid_types,
213
+ filename: e.filename,
182
214
  ),
183
215
  help_suggestion: ShopifyCLI::Context.message(
184
216
  "script.error.configuration_schema_field_invalid_value_error_help"
@@ -239,6 +271,11 @@ module Script
239
271
  cause_of_error: ShopifyCLI::Context.message("script.error.script_upload_cause"),
240
272
  help_suggestion: ShopifyCLI::Context.message("script.error.script_upload_help"),
241
273
  }
274
+ when Layers::Infrastructure::Errors::ScriptTooLargeError
275
+ {
276
+ cause_of_error: ShopifyCLI::Context.message("script.error.script_too_large_cause"),
277
+ help_suggestion: ShopifyCLI::Context.message("script.error.script_too_large_help", max_size: e.max_size),
278
+ }
242
279
  when Layers::Infrastructure::Errors::APILibraryNotFoundError
243
280
  {
244
281
  cause_of_error: ShopifyCLI::Context
@@ -4,6 +4,9 @@ require "theme_check"
4
4
  module Theme
5
5
  class Command
6
6
  class Check < ShopifyCLI::Command::SubCommand
7
+ recommend_default_node_range
8
+ recommend_default_ruby_range
9
+
7
10
  class Options < ShopifyCLI::Options
8
11
  def initialize(theme_check)
9
12
  super()
@@ -5,6 +5,9 @@ require "shopify_cli/theme/development_theme"
5
5
  module Theme
6
6
  class Command
7
7
  class Delete < ShopifyCLI::Command::SubCommand
8
+ recommend_default_node_range
9
+ recommend_default_ruby_range
10
+
8
11
  options do |parser, flags|
9
12
  parser.on("-d", "--development") { flags[:development] = true }
10
13
  parser.on("-a", "--show-all") { flags[:show_all] = true }
@@ -3,6 +3,9 @@
3
3
  module Theme
4
4
  class Command
5
5
  class Init < ShopifyCLI::Command::SubCommand
6
+ recommend_default_node_range
7
+ recommend_default_ruby_range
8
+
6
9
  options do |parser, flags|
7
10
  parser.on("-u", "--clone-url URL") { |url| flags[:clone_url] = url }
8
11
  end
@@ -4,6 +4,9 @@ require "theme_check"
4
4
  module Theme
5
5
  class Command
6
6
  class LanguageServer < ShopifyCLI::Command::SubCommand
7
+ recommend_default_node_range
8
+ recommend_default_ruby_range
9
+
7
10
  def call(*)
8
11
  ThemeCheck::LanguageServer.start
9
12
  end
@@ -5,6 +5,9 @@ require "json"
5
5
  module Theme
6
6
  class Command
7
7
  class Package < ShopifyCLI::Command::SubCommand
8
+ recommend_default_node_range
9
+ recommend_default_ruby_range
10
+
8
11
  THEME_DIRECTORIES = %w[
9
12
  assets
10
13
  config
@@ -4,6 +4,9 @@ require "shopify_cli/theme/theme"
4
4
  module Theme
5
5
  class Command
6
6
  class Publish < ShopifyCLI::Command::SubCommand
7
+ recommend_default_node_range
8
+ recommend_default_ruby_range
9
+
7
10
  options do |parser, flags|
8
11
  parser.on("-f", "--force") { flags[:force] = true }
9
12
  end
@@ -1,17 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
  require "shopify_cli/theme/theme"
3
3
  require "shopify_cli/theme/ignore_filter"
4
+ require "shopify_cli/theme/include_filter"
4
5
  require "shopify_cli/theme/syncer"
5
6
 
6
7
  module Theme
7
8
  class Command
8
9
  class Pull < ShopifyCLI::Command::SubCommand
10
+ recommend_default_node_range
11
+ recommend_default_ruby_range
12
+
9
13
  options do |parser, flags|
10
14
  parser.on("-n", "--nodelete") { flags[:nodelete] = true }
11
15
  parser.on("-i", "--themeid=ID") { |theme_id| flags[:theme_id] = theme_id }
12
16
  parser.on("-t", "--theme=NAME_OR_ID") { |theme| flags[:theme] = theme }
13
17
  parser.on("-l", "--live") { flags[:live] = true }
14
18
  parser.on("-d", "--development") { flags[:development] = true }
19
+ parser.on("-o", "--only=PATTERN") do |pattern|
20
+ flags[:includes] ||= []
21
+ flags[:includes] << pattern
22
+ end
15
23
  parser.on("-x", "--ignore=PATTERN") do |pattern|
16
24
  flags[:ignores] ||= []
17
25
  flags[:ignores] << pattern
@@ -24,10 +32,13 @@ module Theme
24
32
  theme = find_theme(root, **options.flags)
25
33
  return if theme.nil?
26
34
 
35
+ include_filter = ShopifyCLI::Theme::IncludeFilter.new(options.flags[:includes])
27
36
  ignore_filter = ShopifyCLI::Theme::IgnoreFilter.from_path(root)
28
37
  ignore_filter.add_patterns(options.flags[:ignores]) if options.flags[:ignores]
29
38
 
30
- syncer = ShopifyCLI::Theme::Syncer.new(@ctx, theme: theme, ignore_filter: ignore_filter)
39
+ syncer = ShopifyCLI::Theme::Syncer.new(@ctx, theme: theme,
40
+ include_filter: include_filter,
41
+ ignore_filter: ignore_filter)
31
42
  begin
32
43
  syncer.start_threads
33
44
  CLI::UI::Frame.open(@ctx.message("theme.pull.pulling", theme.name, theme.id, theme.shop)) do