shopify-cli 2.6.4 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer.json +5 -0
  3. data/.github/DESIGN.md +1 -1
  4. data/.github/ISSUE_TEMPLATE.md +7 -0
  5. data/.gitignore +1 -0
  6. data/.vscode/extensions.json +5 -0
  7. data/.vscode/settings.json +9 -0
  8. data/CHANGELOG.md +35 -3
  9. data/CONTRIBUTING.md +1 -21
  10. data/{Dockerfile → Codespace.dockerfile} +11 -3
  11. data/Gemfile +1 -0
  12. data/Gemfile.lock +6 -4
  13. data/README.md +20 -99
  14. data/Rakefile +27 -0
  15. data/Tests.dockerfile +35 -0
  16. data/assets/logo.png +0 -0
  17. data/dev.yml +0 -3
  18. data/docs/README.md +13 -0
  19. data/docs/contributors/testing.md +27 -0
  20. data/docs/users/installation.md +46 -0
  21. data/{THEMEKIT_MIGRATION.md → docs/users/migrate-from-themekit.md} +1 -1
  22. data/ext/javy/javy.rb +186 -0
  23. data/ext/javy/version +1 -0
  24. data/lib/project_types/extension/cli.rb +7 -3
  25. data/lib/project_types/extension/commands/build.rb +1 -0
  26. data/lib/project_types/extension/commands/create.rb +6 -6
  27. data/lib/project_types/extension/commands/extension_command.rb +1 -1
  28. data/lib/project_types/extension/features/argo.rb +1 -8
  29. data/lib/project_types/extension/features/argo_serve.rb +9 -23
  30. data/lib/project_types/extension/forms/create.rb +1 -1
  31. data/lib/project_types/extension/forms/questions/ask_template.rb +3 -6
  32. data/lib/project_types/extension/messages/messages.rb +1 -0
  33. data/lib/project_types/extension/models/development_server_requirements.rb +2 -3
  34. data/lib/project_types/extension/models/server_config/app.rb +13 -0
  35. data/lib/project_types/extension/models/server_config/development.rb +5 -4
  36. data/lib/project_types/extension/models/server_config/development_renderer.rb +1 -1
  37. data/lib/project_types/extension/models/server_config/development_resource.rb +13 -0
  38. data/lib/project_types/extension/models/server_config/extension.rb +4 -0
  39. data/lib/project_types/extension/models/server_config/root.rb +4 -1
  40. data/lib/project_types/extension/tasks/convert_server_config.rb +65 -0
  41. data/lib/project_types/extension/tasks/ensure_resource_url.rb +39 -0
  42. data/lib/project_types/extension/tasks/find_package_from_json.rb +37 -0
  43. data/lib/project_types/extension/tasks/merge_server_config.rb +32 -0
  44. data/lib/project_types/extension/tasks/run_extension_command.rb +11 -10
  45. data/lib/project_types/node/cli.rb +0 -16
  46. data/lib/project_types/node/forms/create.rb +5 -5
  47. data/lib/project_types/node/messages/messages.rb +2 -144
  48. data/lib/project_types/php/cli.rb +0 -11
  49. data/lib/project_types/php/forms/create.rb +5 -6
  50. data/lib/project_types/php/messages/messages.rb +2 -161
  51. data/lib/project_types/rails/cli.rb +0 -16
  52. data/lib/project_types/rails/commands/create.rb +46 -17
  53. data/lib/project_types/rails/forms/create.rb +5 -7
  54. data/lib/project_types/rails/messages/messages.rb +6 -151
  55. data/lib/project_types/script/cli.rb +2 -1
  56. data/lib/project_types/script/commands/create.rb +2 -5
  57. data/lib/project_types/script/commands/javy.rb +31 -0
  58. data/lib/project_types/script/commands/push.rb +1 -1
  59. data/lib/project_types/script/config/extension_points.yml +3 -0
  60. data/lib/project_types/script/errors.rb +0 -18
  61. data/lib/project_types/script/layers/application/create_script.rb +2 -2
  62. data/lib/project_types/script/layers/domain/script_json.rb +1 -1
  63. data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -4
  64. data/lib/project_types/script/layers/infrastructure/errors.rb +8 -3
  65. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +22 -3
  66. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +25 -0
  67. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +3 -4
  68. data/lib/project_types/script/layers/infrastructure/script_service.rb +1 -1
  69. data/lib/project_types/script/messages/messages.rb +16 -22
  70. data/lib/project_types/script/ui/error_handler.rb +1 -27
  71. data/lib/project_types/theme/cli.rb +1 -1
  72. data/lib/project_types/theme/commands/check.rb +1 -1
  73. data/lib/project_types/theme/commands/delete.rb +1 -1
  74. data/lib/project_types/theme/commands/init.rb +1 -1
  75. data/lib/project_types/theme/commands/language_server.rb +1 -1
  76. data/lib/project_types/theme/commands/package.rb +1 -1
  77. data/lib/project_types/theme/commands/publish.rb +1 -1
  78. data/lib/project_types/theme/commands/pull.rb +1 -1
  79. data/lib/project_types/theme/commands/push.rb +1 -1
  80. data/lib/project_types/theme/commands/serve.rb +9 -2
  81. data/lib/project_types/theme/messages/messages.rb +30 -1
  82. data/lib/shopify_cli/admin_api/populate_resource_command.rb +1 -1
  83. data/lib/shopify_cli/api.rb +7 -2
  84. data/lib/shopify_cli/app_type_detector.rb +24 -20
  85. data/lib/shopify_cli/command/app_sub_command.rb +10 -0
  86. data/lib/shopify_cli/command/project_command.rb +18 -0
  87. data/lib/shopify_cli/command/sub_command.rb +19 -0
  88. data/lib/shopify_cli/command.rb +7 -2
  89. data/lib/shopify_cli/commands/app/connect.rb +22 -0
  90. data/lib/shopify_cli/commands/app/create/node.rb +38 -0
  91. data/lib/shopify_cli/commands/app/create/php.rb +36 -0
  92. data/lib/shopify_cli/commands/app/create/rails.rb +40 -0
  93. data/lib/shopify_cli/commands/app/create.rb +28 -0
  94. data/lib/shopify_cli/commands/app/deploy.rb +49 -0
  95. data/lib/shopify_cli/commands/app/open.rb +19 -0
  96. data/lib/shopify_cli/commands/app/serve.rb +49 -0
  97. data/lib/shopify_cli/commands/app/tunnel.rb +43 -0
  98. data/lib/shopify_cli/commands/app.rb +29 -0
  99. data/lib/shopify_cli/commands/config.rb +2 -2
  100. data/lib/shopify_cli/commands.rb +1 -0
  101. data/lib/shopify_cli/constants.rb +4 -0
  102. data/lib/shopify_cli/exception_reporter.rb +8 -6
  103. data/lib/shopify_cli/git.rb +12 -1
  104. data/lib/shopify_cli/github/issue_url_generator.rb +19 -0
  105. data/lib/shopify_cli/github.rb +5 -0
  106. data/lib/shopify_cli/messages/messages.rb +253 -9
  107. data/lib/shopify_cli/migrator.rb +9 -11
  108. data/lib/shopify_cli/project.rb +5 -1
  109. data/lib/shopify_cli/project_commands.rb +1 -1
  110. data/lib/shopify_cli/services/app/connect_service.rb +25 -0
  111. data/lib/shopify_cli/services/app/create/node_service.rb +155 -0
  112. data/lib/shopify_cli/services/app/create/php_service.rb +152 -0
  113. data/lib/shopify_cli/services/app/create/rails_service.rb +215 -0
  114. data/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +101 -0
  115. data/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +135 -0
  116. data/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +120 -0
  117. data/lib/shopify_cli/services/app/open_service.rb +19 -0
  118. data/lib/shopify_cli/services/app/serve/node_service.rb +42 -0
  119. data/lib/shopify_cli/services/app/serve/php_service.rb +46 -0
  120. data/lib/shopify_cli/services/app/serve/rails_service.rb +48 -0
  121. data/lib/shopify_cli/services/app/tunnel/auth_service.rb +21 -0
  122. data/lib/shopify_cli/services/app/tunnel/start_service.rb +20 -0
  123. data/lib/shopify_cli/services/app/tunnel/stop_service.rb +20 -0
  124. data/lib/shopify_cli/services.rb +31 -0
  125. data/lib/shopify_cli/theme/dev_server/local_assets.rb +1 -1
  126. data/lib/shopify_cli/theme/dev_server.rb +35 -17
  127. data/lib/shopify_cli/tunnel.rb +25 -20
  128. data/lib/shopify_cli/version.rb +1 -1
  129. data/lib/shopify_cli.rb +1 -2
  130. data/shopify-cli.gemspec +2 -6
  131. data/shopify-dev +18 -0
  132. data/utilities/constants.rb +7 -0
  133. data/utilities/docker/container.rb +30 -2
  134. data/utilities/docker.rb +3 -2
  135. data/utilities/utilities.rb +1 -0
  136. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +1 -1
  137. metadata +56 -53
  138. data/docs/_config.yml +0 -2
  139. data/docs/app/node/commands/index.md +0 -4
  140. data/docs/app/node/index.md +0 -4
  141. data/docs/app/rails/commands/index.md +0 -4
  142. data/docs/app/rails/index.md +0 -4
  143. data/docs/core/index.md +0 -4
  144. data/docs/getting-started/index.md +0 -4
  145. data/docs/getting-started/install/index.md +0 -4
  146. data/docs/getting-started/migrate/index.md +0 -4
  147. data/docs/getting-started/uninstall/index.md +0 -4
  148. data/docs/getting-started/upgrade/index.md +0 -4
  149. data/docs/help/start-app/index.md +0 -4
  150. data/docs/index.md +0 -4
  151. data/ext/shopify-cli/extconf.rb +0 -60
  152. data/install.sh +0 -7
  153. data/lib/project_types/extension/tasks/converters/server_config_converter.rb +0 -31
  154. data/lib/project_types/extension/tasks/load_server_config.rb +0 -23
  155. data/lib/project_types/node/commands/connect.rb +0 -21
  156. data/lib/project_types/node/commands/create.rb +0 -125
  157. data/lib/project_types/node/commands/deploy/heroku.rb +0 -96
  158. data/lib/project_types/node/commands/deploy.rb +0 -32
  159. data/lib/project_types/node/commands/generate.rb +0 -22
  160. data/lib/project_types/node/commands/open.rb +0 -18
  161. data/lib/project_types/node/commands/serve.rb +0 -45
  162. data/lib/project_types/node/commands/tunnel.rb +0 -41
  163. data/lib/project_types/php/commands/connect.rb +0 -19
  164. data/lib/project_types/php/commands/create.rb +0 -143
  165. data/lib/project_types/php/commands/deploy/heroku.rb +0 -129
  166. data/lib/project_types/php/commands/deploy.rb +0 -32
  167. data/lib/project_types/php/commands/open.rb +0 -16
  168. data/lib/project_types/php/commands/serve.rb +0 -48
  169. data/lib/project_types/php/commands/tunnel.rb +0 -37
  170. data/lib/project_types/rails/commands/connect.rb +0 -21
  171. data/lib/project_types/rails/commands/deploy/heroku.rb +0 -115
  172. data/lib/project_types/rails/commands/deploy.rb +0 -32
  173. data/lib/project_types/rails/commands/generate/webhook.rb +0 -42
  174. data/lib/project_types/rails/commands/generate.rb +0 -60
  175. data/lib/project_types/rails/commands/open.rb +0 -18
  176. data/lib/project_types/rails/commands/serve.rb +0 -51
  177. data/lib/project_types/rails/commands/tunnel.rb +0 -41
  178. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -0
  179. data/lib/shopify_cli/sub_command.rb +0 -17
  180. data/shopify.fish +0 -12
  181. data/shopify.sh +0 -11
@@ -5,8 +5,8 @@ module Rails
5
5
  MESSAGES = {
6
6
  rails: {
7
7
  help: <<~HELP,
8
- Suite of commands for developing Ruby on Rails apps. See {{command:%1$s rails <command> --help}} for usage of each command.
9
- Usage: {{command:%1$s rails [ %2$s ]}}
8
+ Suite of commands for developing Ruby on Rails apps. See {{command:%1$s app rails <command> --help}} for usage of each command.
9
+ Usage: {{command:%1$s app rails [ %2$s ]}}
10
10
  HELP
11
11
 
12
12
  error: {
@@ -21,117 +21,22 @@ module Rails
21
21
  setting_gem_home: "GEM_HOME being set to %s",
22
22
  setting_gem_path: "GEM_PATH being set to %s",
23
23
  },
24
-
25
- connect: {
26
- connected: "Project now connected to {{green:%s}}",
27
- help: <<~HELP,
28
- {{command:%s rails connect}}: Connects an existing Ruby on Rails app to Shopify CLI. Creates a config file.
29
- Usage: {{command:%s rails connect}}
30
- HELP
31
- production_warning: <<~MESSAGE,
32
- {{yellow:! Warning: if you have connected to an {{bold:app in production}}, running {{command:serve}} may update the app URL and cause an outage.
33
- MESSAGE
34
- },
35
-
36
- create: {
37
- help: <<~HELP,
38
- {{command:%s rails create}}: Creates a ruby on rails app.
39
- Usage: {{command:%s rails create}}
40
- Options:
41
- {{command:--name=NAME}} App name. Any string.
42
- {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization.
43
- {{command:--store=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store.
44
- {{command:--db=DB}} Database type. Must be one of: mysql, postgresql, sqlite3, oracle, frontbase, ibm_db, sqlserver, jdbcmysql, jdbcsqlite3, jdbcpostgresql, jdbc.
45
- {{command:--rails-opts=RAILSOPTS}} Additional options. Must be string containing one or more valid Rails options, separated by spaces.
46
- HELP
47
-
48
- error: {
49
- invalid_ruby_version: "This project requires a Ruby version ~> 2.5 or Ruby 3.0.",
50
- dir_exists: "Project directory %s already exists. Please use a different name.",
51
- install_failure: "Error installing %s gem",
52
- node_required: "node is required to create a rails project. Download at https://nodejs.org/en/download.",
53
- node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \
54
- "per the instructions at https://nodejs.org/en.",
55
- yarn_required: "yarn is required to create a rails project. Download at " \
56
- "https://classic.yarnpkg.com/en/docs/install.",
57
- yarn_version_failure: "Failed to get the current yarn version. Please make sure it is installed as per " \
58
- "the instructions at https://classic.yarnpkg.com/en/docs/install.",
59
- },
60
-
61
- info: {
62
- open_new_shell: "{{*}} {{yellow:After installing %s, please open a new Command Prompt or PowerShell " \
63
- "window to continue.}}",
64
- },
65
- installing_bundler: "Installing bundler…",
66
- generating_app: "Generating new rails app project in %s…",
67
- adding_shopify_gem: "{{v}} Adding shopify_app gem…",
68
- node_version: "node %s",
69
- yarn_version: "yarn %s",
70
- running_bundle_install: "Running bundle install…",
71
- running_generator: "Running shopify_app generator…",
72
- running_migrations: "Running migrations…",
73
- running_webpacker_install: "Running webpacker:install…",
74
- },
75
-
76
24
  deploy: {
77
25
  help: <<~HELP,
78
26
  Deploy the current Rails project to a hosting service. Heroku ({{underline:https://www.heroku.com}}) is currently the only option, but more will be added in the future.
79
- Usage: {{command:%s rails deploy [ heroku ]}}
27
+ Usage: {{command:%s app rails deploy [ heroku ]}}
80
28
  HELP
81
29
  extended_help: <<~HELP,
82
30
  {{bold:Subcommands:}}
83
31
  {{cyan:heroku}}: Deploys the current Rails project to Heroku.
84
- Usage: {{command:%s rails deploy heroku}}
32
+ Usage: {{command:%s app rails deploy heroku}}
85
33
  HELP
86
-
87
- heroku: {
88
- help: <<~HELP,
89
- Deploy the current Rails project to Heroku
90
- Usage: {{command:%s rails deploy heroku}}
91
- HELP
92
- downloading: "Downloading Heroku CLI…",
93
- downloaded: "Downloaded Heroku CLI",
94
- installing: "Installing Heroku CLI…",
95
- installed: "Installed Heroku CLI",
96
- authenticated_with_account: "{{v}} Authenticated with Heroku as {{green:%s}}",
97
- authenticating: "Authenticating with Heroku…",
98
- authenticated: "{{v}} Authenticated with Heroku",
99
- deploying: "Deploying to Heroku…",
100
- deployed: "{{v}} Deployed to Heroku",
101
- db_check: {
102
- validating: "Validating application…",
103
- checking: "Checking database type…",
104
- validated: "Database type \"%s\" validated for platform \"Heroku\"",
105
- problem: "A problem was encountered while checking your database type.",
106
- sqlite: <<~SQLITE,
107
- Heroku does not support deployment using the SQLite database system.
108
- Change the database type using {{command:rails db:system:change --to=[new_db_type]}}. For more info:
109
- {{underline:https://gorails.com/episodes/rails-6-db-system-change-command}}
110
- SQLITE
111
- },
112
- git: {
113
- checking: "Checking git repo…",
114
- initialized: "Git repo initialized",
115
- what_branch: "What branch would you like to deploy?",
116
- branch_selected: "{{v}} Git branch {{green:%s}} selected for deploy",
117
- },
118
- app: {
119
- no_apps_found: "No existing Heroku app found. What would you like to do?",
120
- name: "What is your Heroku app’s name?",
121
- select: "Specify an existing Heroku app",
122
- selecting: "Selecting Heroku app %s…",
123
- selected: "{{v}} Heroku app {{green:%s}} selected",
124
- create: "Create a new Heroku app",
125
- creating: "Creating new Heroku app…",
126
- created: "{{v}} New Heroku app created",
127
- },
128
- },
129
34
  },
130
35
 
131
36
  generate: {
132
37
  help: <<~HELP,
133
38
  Generate code in your Rails project. Currently supports generating new webhooks.
134
- Usage: {{command:%s rails generate [ webhook ]}}
39
+ Usage: {{command:%s app rails generate [ webhook ]}}
135
40
  HELP
136
41
  extended_help: <<~EXAMPLES,
137
42
  {{bold:Examples:}}
@@ -147,63 +52,13 @@ module Rails
147
52
  webhook: {
148
53
  help: <<~HELP,
149
54
  Generate and register a new webhook that listens for the specified Shopify store event.
150
- Usage: {{command:%s rails generate webhook <type>}}
55
+ Usage: {{command:%s app rails generate webhook <type>}}
151
56
  HELP
152
57
 
153
58
  select: "What type of webhook would you like to create?",
154
59
  selected: "Generating webhook: %s",
155
60
  },
156
61
  },
157
-
158
- open: {
159
- help: <<~HELP,
160
- Open your local development app in the default browser.
161
- Usage: {{command:%s rails open}}
162
- HELP
163
- },
164
-
165
- serve: {
166
- help: <<~HELP,
167
- Start a local development rails server for your project, as well as a public ngrok tunnel to your localhost.
168
- Usage: {{command:%s rails serve}}
169
- HELP
170
- extended_help: <<~HELP,
171
- {{bold:Options:}}
172
- {{cyan:--host=HOST}}: Bypass running tunnel and use custom host. HOST must be HTTPS url.
173
- {{cyan:--port=PORT}}: Use custom port.
174
- HELP
175
-
176
- open_info: <<~MESSAGE,
177
- {{*}} To install and start using your app, open this URL in your browser:
178
- {{green:%s}}
179
- MESSAGE
180
- running_server: "Running server…",
181
- },
182
-
183
- tunnel: {
184
- help: <<~HELP,
185
- Start or stop an http tunnel to your local development app using ngrok.
186
- Usage: {{command:%s rails tunnel [ auth | start | stop ]}}
187
- HELP
188
- extended_help: <<~HELP,
189
- {{bold:Subcommands:}}
190
-
191
- {{cyan:auth}}: Writes an ngrok auth token to ~/.ngrok2/ngrok.yml to connect with an ngrok account. Visit https://dashboard.ngrok.com/signup to sign up.
192
- Usage: {{command:%1$s rails tunnel auth <token>}}
193
-
194
- {{cyan:start}}: Starts an ngrok tunnel, will print the URL for an existing tunnel if already running.
195
- Usage: {{command:%1$s rails tunnel start}}
196
-
197
- {{cyan:stop}}: Stops the ngrok tunnel.
198
- Usage: {{command:%1$s rails tunnel stop}}
199
-
200
- HELP
201
-
202
- error: {
203
- token_argument_missing: "{{x}} {{red:auth requires a token argument}}\n\n",
204
- },
205
- },
206
-
207
62
  forms: {
208
63
  create: {
209
64
  error: {
@@ -9,10 +9,11 @@ module Script
9
9
  end
10
10
 
11
11
  # define/autoload project specific Commands
12
- class Command < ShopifyCLI::ProjectCommands
12
+ class Command < ShopifyCLI::Command::ProjectCommand
13
13
  hidden_feature(feature_set: :script_project)
14
14
  subcommand :Create, "create", Project.project_filepath("commands/create")
15
15
  subcommand :Push, "push", Project.project_filepath("commands/push")
16
+ subcommand :Javy, "javy", Project.project_filepath("commands/javy")
16
17
  end
17
18
  ShopifyCLI::Commands.register("Script::Command", "script")
18
19
 
@@ -2,18 +2,16 @@
2
2
 
3
3
  module Script
4
4
  class Command
5
- class Create < ShopifyCLI::SubCommand
5
+ class Create < ShopifyCLI::Command::SubCommand
6
6
  unless ShopifyCLI::Environment.acceptance_test?
7
7
  prerequisite_task :ensure_authenticated
8
8
  end
9
9
 
10
10
  options do |parser, flags|
11
11
  parser.on("--name=NAME") { |name| flags[:name] = name }
12
- parser.on("--extension_point=EP_NAME") { |ep_name| flags[:extension_point] = ep_name }
13
- parser.on("--extension-point=EP_NAME") { |ep_name| flags[:extension_point] = ep_name }
12
+ parser.on("--api=API_NAME") { |ep_name| flags[:extension_point] = ep_name }
14
13
  parser.on("--language=LANGUAGE") { |language| flags[:language] = language }
15
14
  parser.on("--branch=BRANCH") { |branch| flags[:branch] = branch }
16
- parser.on("--no-config-ui") { |no_config_ui| flags[:no_config_ui] = no_config_ui }
17
15
  end
18
16
 
19
17
  def call(args, _name)
@@ -30,7 +28,6 @@ module Script
30
28
  sparse_checkout_branch: options.flags[:branch] || "master",
31
29
  script_name: form.name,
32
30
  extension_point_type: form.extension_point,
33
- no_config_ui: options.flags.key?(:no_config_ui)
34
31
  )
35
32
  @ctx.puts(@ctx.message("script.create.change_directory_notice", project.script_name))
36
33
  rescue StandardError => e
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ require "shopify_cli"
3
+ require_relative "../../../../ext/javy/javy.rb"
4
+
5
+ module Script
6
+ class Command
7
+ class Javy < ShopifyCLI::Command::SubCommand
8
+ hidden_feature
9
+
10
+ prerequisite_task ensure_project_type: :script
11
+
12
+ options do |parser, flags|
13
+ parser.on("--in=IN") { |in_file| flags[:in_file] = in_file }
14
+ parser.on("--out=OUT") { |out_file| flags[:out_file] = out_file }
15
+ end
16
+
17
+ def call(*)
18
+ source = options.flags[:in_file]
19
+ dest = options.flags[:out_file]
20
+
21
+ @ctx.abort(@ctx.message("script.javy.errors.invalid_arguments", ShopifyCLI::TOOL_NAME)) unless source
22
+
23
+ ::Javy.build(source: source, dest: dest).unwrap { |e| @ctx.abort(e.message) }
24
+ end
25
+
26
+ def self.help
27
+ ShopifyCLI::Context.message("script.javy.help", ShopifyCLI::TOOL_NAME)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Script
4
4
  class Command
5
- class Push < ShopifyCLI::SubCommand
5
+ class Push < ShopifyCLI::Command::SubCommand
6
6
  prerequisite_task ensure_project_type: :script
7
7
 
8
8
  options do |parser, flags|
@@ -32,6 +32,7 @@ payment_methods:
32
32
  package: "@shopify/scripts-checkout-apis"
33
33
  typescript:
34
34
  beta: true
35
+ package: "@shopify/scripts-checkout-apis"
35
36
  repo: "https://github.com/Shopify/scripts-apis-examples"
36
37
  shipping_methods:
37
38
  domain: 'checkout'
@@ -41,6 +42,7 @@ shipping_methods:
41
42
  package: "@shopify/scripts-checkout-apis"
42
43
  typescript:
43
44
  beta: true
45
+ package: "@shopify/scripts-checkout-apis"
44
46
  repo: "https://github.com/Shopify/scripts-apis-examples"
45
47
  discount_types:
46
48
  beta: true
@@ -48,4 +50,5 @@ discount_types:
48
50
  libraries:
49
51
  typescript:
50
52
  beta: true
53
+ package: "@shopify/scripts-discount-apis"
51
54
  repo: "https://github.com/Shopify/scripts-apis-examples"
@@ -6,23 +6,5 @@ module Script
6
6
 
7
7
  class NoExistingAppsError < ScriptProjectError; end
8
8
  class NoExistingOrganizationsError < ScriptProjectError; end
9
-
10
- class NoExistingStoresError < ScriptProjectError
11
- attr_reader :organization_id
12
- def initialize(organization_id)
13
- super()
14
- @organization_id = organization_id
15
- end
16
- end
17
-
18
- class InvalidConfigProps < ScriptProjectError; end
19
-
20
- class InvalidConfigYAMLError < ScriptProjectError
21
- attr_reader :config_file
22
- def initialize(config_file)
23
- super()
24
- @config_file = config_file
25
- end
26
- end
27
9
  end
28
10
  end
@@ -7,7 +7,7 @@ module Script
7
7
  module Application
8
8
  class CreateScript
9
9
  class << self
10
- def call(ctx:, language:, sparse_checkout_branch:, script_name:, extension_point_type:, no_config_ui:)
10
+ def call(ctx:, language:, sparse_checkout_branch:, script_name:, extension_point_type:)
11
11
  raise Infrastructure::Errors::ScriptProjectAlreadyExistsError, script_name if ctx.dir_exist?(script_name)
12
12
 
13
13
  in_new_directory_context(ctx, script_name) do
@@ -36,7 +36,7 @@ module Script
36
36
  )
37
37
 
38
38
  install_dependencies(ctx, language, script_name, project_creator)
39
- script_project_repo.update_or_create_script_json(title: script_name, configuration_ui: !no_config_ui)
39
+ script_project_repo.update_or_create_script_json(title: script_name)
40
40
  project
41
41
  end
42
42
  end
@@ -15,7 +15,7 @@ module Script
15
15
  @version = @content["version"].to_s
16
16
  @title = @content["title"]
17
17
  @description = @content["description"]
18
- @configuration_ui = @content["configurationUi"]
18
+ @configuration_ui = @content.fetch("configurationUi", true)
19
19
  @configuration = @content["configuration"]
20
20
  end
21
21
 
@@ -27,10 +27,6 @@ module Script
27
27
  case error_code(response["errors"])
28
28
  when "forbidden"
29
29
  raise Errors::ForbiddenError
30
- when "forbidden_on_shop"
31
- raise Errors::ShopAuthenticationError
32
- when "app_not_installed_on_shop"
33
- raise Errors::AppNotInstalledError
34
30
  else
35
31
  raise Errors::GraphqlError, response["errors"]
36
32
  end
@@ -4,7 +4,6 @@ module Script
4
4
  module Layers
5
5
  module Infrastructure
6
6
  module Errors
7
- class AppNotInstalledError < ScriptProjectError; end
8
7
  class BuildError < ScriptProjectError; end
9
8
  class ScriptJsonSyntaxError < ScriptProjectError; end
10
9
 
@@ -57,8 +56,15 @@ module Script
57
56
  end
58
57
  end
59
58
 
59
+ class DeprecatedEPError < ScriptProjectError
60
+ attr_reader(:extension_point)
61
+ def initialize(extension_point)
62
+ super()
63
+ @extension_point = extension_point
64
+ end
65
+ end
66
+
60
67
  class DependencyInstallError < ScriptProjectError; end
61
- class DeprecatedEPError < ScriptProjectError; end
62
68
  class EmptyResponseError < ScriptProjectError; end
63
69
  class InvalidResponseError < ScriptProjectError; end
64
70
  class ForbiddenError < ScriptProjectError; end
@@ -101,7 +107,6 @@ module Script
101
107
  end
102
108
 
103
109
  class ScriptProjectAlreadyExistsError < ScriptProjectError; end
104
- class ShopAuthenticationError < ScriptProjectError; end
105
110
  class TaskRunnerNotFoundError < ScriptProjectError; end
106
111
  class BuildScriptNotFoundError < ScriptProjectError; end
107
112
  class InvalidBuildScriptError < ScriptProjectError; end
@@ -48,13 +48,32 @@ module Script
48
48
  end
49
49
 
50
50
  def library_version(library_name)
51
- output = JSON.parse(CommandRunner.new(ctx: ctx).call("npm list --json"))
52
- raise Errors::APILibraryNotFoundError.new(library_name), output unless output["dependencies"][library_name]
53
- output["dependencies"][library_name]["version"]
51
+ output = JSON.parse(CommandRunner.new(ctx: ctx).call("npm -s list --json"))
52
+ library_version_from_npm_list(output, library_name)
53
+ rescue Errors::SystemCallFailureError => error
54
+ library_version_from_npm_list_error_output(error, library_name)
54
55
  end
55
56
 
56
57
  private
57
58
 
59
+ def library_version_from_npm_list_error_output(error, library_name)
60
+ # npm list can return a failure status code, even when returning the correct data.
61
+ # This causes the CommandRunner to throw a SystemCallFailure error that contains the data.
62
+ # In here, we check that the output contains `npm list`'s structure and extract the version.
63
+ output = JSON.parse(error.out)
64
+ raise error unless output.key?("dependencies")
65
+
66
+ library_version_from_npm_list(output, library_name)
67
+ rescue JSON::ParserError
68
+ raise error
69
+ end
70
+
71
+ def library_version_from_npm_list(output, library_name)
72
+ output.dig("dependencies", library_name, "version").tap do |version|
73
+ raise Errors::APILibraryNotFoundError, library_name unless version
74
+ end
75
+ end
76
+
58
77
  def check_node_version!
59
78
  output, status = @ctx.capture2e("node", "--version")
60
79
  raise Errors::DependencyInstallError, output unless status.success?
@@ -48,8 +48,33 @@ module Script
48
48
  Domain::Metadata.create_from_json(@ctx, raw_contents)
49
49
  end
50
50
 
51
+ def library_version(library_name)
52
+ output = JSON.parse(CommandRunner.new(ctx: ctx).call("npm -s list --json"))
53
+ library_version_from_npm_list(output, library_name)
54
+ rescue Errors::SystemCallFailureError => error
55
+ library_version_from_npm_list_error_output(error, library_name)
56
+ end
57
+
51
58
  private
52
59
 
60
+ def library_version_from_npm_list_error_output(error, library_name)
61
+ # npm list can return a failure status code, even when returning the correct data.
62
+ # This causes the CommandRunner to throw a SystemCallFailure error that contains the data.
63
+ # In here, we check that the output contains `npm list`'s structure and extract the version.
64
+ output = JSON.parse(error.out)
65
+ raise error unless output.key?("dependencies")
66
+
67
+ library_version_from_npm_list(output, library_name)
68
+ rescue JSON::ParserError
69
+ raise error
70
+ end
71
+
72
+ def library_version_from_npm_list(output, library_name)
73
+ output.dig("dependencies", library_name, "version").tap do |version|
74
+ raise Errors::APILibraryNotFoundError, library_name unless version
75
+ end
76
+ end
77
+
53
78
  def check_node_version!
54
79
  output, status = @ctx.capture2e("node", "--version")
55
80
  raise Errors::DependencyInstallError, output unless status.success?
@@ -81,10 +81,10 @@ module Script
81
81
  )
82
82
  end
83
83
 
84
- def update_or_create_script_json(title:, configuration_ui: false)
84
+ def update_or_create_script_json(title:)
85
85
  script_json = ScriptJsonRepository
86
86
  .new(ctx: ctx)
87
- .update_or_create(title: title, configuration_ui: configuration_ui)
87
+ .update_or_create(title: title)
88
88
 
89
89
  Domain::ScriptProject.new(
90
90
  id: ctx.root,
@@ -148,11 +148,10 @@ module Script
148
148
  current_script_json || raise(Domain::Errors::NoScriptJsonFile)
149
149
  end
150
150
 
151
- def update_or_create(title:, configuration_ui:)
151
+ def update_or_create(title:)
152
152
  json = current_script_json&.content || {}
153
153
  json["version"] ||= "1"
154
154
  json["title"] = title
155
- json["configurationUi"] = !!configuration_ui
156
155
 
157
156
  ctx.write(SCRIPT_JSON_FILENAME, JSON.pretty_generate(json))
158
157
 
@@ -46,7 +46,7 @@ module Script
46
46
 
47
47
  if user_errors.any? { |e| e["tag"] == "already_exists_error" }
48
48
  raise Errors::ScriptRepushError, uuid
49
- elsif (e = user_errors.any? { |err| err["tag"] == "configuration_syntax_error" })
49
+ elsif (e = user_errors.any? { |err| err["tag"] == "configuration_definition_syntax_error" })
50
50
  raise Errors::ScriptJsonSyntaxError
51
51
  elsif (e = user_errors.find { |err| err["tag"] == "configuration_definition_missing_keys_error" })
52
52
  raise Errors::ScriptJsonMissingKeysError, e["message"]
@@ -27,10 +27,6 @@ module Script
27
27
  "extension_point_type or script_name.",
28
28
  invalid_context_help: "Add these values and try again.",
29
29
 
30
- invalid_config_props_cause: "{{command:--config-props}} is formatted incorrectly.",
31
- invalid_config_props_help: "Try again using this format: "\
32
- "{{cyan:--config-props='name1:value1, name2:value2'}}",
33
-
34
30
  invalid_script_name_cause: "Invalid script name.",
35
31
  invalid_script_name_help: "Replace or remove unsupported characters. Valid characters "\
36
32
  "are numbers, letters, hyphens, or underscores.",
@@ -42,9 +38,6 @@ module Script
42
38
  no_existing_orgs_cause: "You don't have any partner organizations.",
43
39
  no_existing_orgs_help: "Visit https://partners.shopify.com/ to create a partners account.",
44
40
 
45
- no_existing_stores_cause: "You don't have any stores in your Partner Dashboard.",
46
- no_existing_stores_help: "Visit https://partners.shopify.com/%{organization_id}/stores/ to create one.",
47
-
48
41
  project_exists_cause: "A directory with this same name already exists.",
49
42
  project_exists_help: "Try again and enter a different name for the script.",
50
43
 
@@ -54,9 +47,6 @@ module Script
54
47
  invalid_language_cause: "Invalid language %s.",
55
48
  invalid_language_help: "Allowed values: %s.",
56
49
 
57
- invalid_config: "Can't change the configuration values because %1$s is missing or "\
58
- "it isn't formatted properly.",
59
-
60
50
  missing_script_json_field_cause: "The script.json file is missing the required %s field.",
61
51
  missing_script_json_field_help: "Add the field and try again.",
62
52
 
@@ -91,8 +81,8 @@ module Script
91
81
  system_call_failure_cause: "An error was returned while running {{command:%{cmd}}}.",
92
82
  system_call_failure_help: "Review the following error and try again.\n{{red:%{out}}}",
93
83
 
94
- metadata_validation_cause: "Invalid Script API metadata.",
95
- metadata_validation_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date.",
84
+ metadata_validation_cause: "The Script API metadata is incorrect.",
85
+ metadata_validation_help: "The 'schemaVersions.major' field contains an unsupported version.",
96
86
 
97
87
  metadata_schema_versions_missing: "Invalid Script metadata:" \
98
88
  " 'schemaVersions' field is missing",
@@ -107,7 +97,6 @@ module Script
107
97
  metadata_not_found_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date and " \
108
98
  "'package.json' contains a 'scripts/build' entry with a " \
109
99
  "'--metadata build/metadata.json' argument",
110
- app_not_installed_cause: "App not installed on store.",
111
100
 
112
101
  build_error_cause: "Something went wrong while building the script.",
113
102
  build_error_help: "Correct the errors and try again.",
@@ -126,9 +115,6 @@ module Script
126
115
  script_repush_cause: "A version of this script already exists on the app.",
127
116
  script_repush_help: "Use {{cyan:--force}} to replace the existing script.",
128
117
 
129
- shop_auth_cause: "Unable to authenticate with the store.",
130
- shop_auth_help: "Try again.",
131
-
132
118
  invalid_build_script: "The root package.json contains an invalid build command that " \
133
119
  "is needed to compile your script to WebAssembly.",
134
120
  build_script_not_found: "The root package.json is missing the build command that " \
@@ -162,8 +148,7 @@ module Script
162
148
  Usage: {{command:%1$s script create}}
163
149
  Options:
164
150
  {{command:--name=NAME}} Script project name. Use any string.
165
- {{command:--extension-point=TYPE}} Script API name. Allowed values: %2$s.
166
- {{command:--no-config-ui}} Specify this option when you don’t want your script to render an interface in Shopify admin.
151
+ {{command:--api=TYPE}} Script API name. Allowed values: %2$s.
167
152
  HELP
168
153
 
169
154
  error: {
@@ -191,6 +176,19 @@ module Script
191
176
  script_pushed: "{{v}} Script pushed to app (API key: %{api_key}).",
192
177
  },
193
178
 
179
+ javy: {
180
+ help: <<~HELP,
181
+ Compile the JavaScript code into WebAssembly.
182
+ Usage: {{command:%s script javy}}
183
+ Options:
184
+ {{command:--in}} The name of the JavaScript file that will be compiled.
185
+ {{command:--out}} The name of the file that the WebAssembly should be written to.
186
+ HELP
187
+ errors: {
188
+ invalid_arguments: "Javy was run with invalid arguments. Run {{command: %s script javy --help}} for more information.",
189
+ },
190
+ },
191
+
194
192
  project_deps: {
195
193
  none_required: "{{v}} None required",
196
194
  checking_with_npm: "Checking dependencies with npm",
@@ -212,10 +210,6 @@ module Script
212
210
  built: "Built",
213
211
  pushing: "Pushing",
214
212
  pushed: "Pushed",
215
- disabling: "Disabling",
216
- disabled: "Disabled",
217
- enabling: "Enabling",
218
- enabled: "Enabled",
219
213
  ensure_env: {
220
214
  organization: "Partner organization {{green:%s (%s)}}.",
221
215
  organization_select: "Which partner organization do you want to use?",