shopify-cli 2.6.6 → 2.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer.json +5 -0
  3. data/.github/CODEOWNERS +2 -2
  4. data/.github/DESIGN.md +1 -1
  5. data/.github/ISSUE_TEMPLATE.md +7 -0
  6. data/.github/workflows/shopify.yml +1 -1
  7. data/.gitignore +1 -0
  8. data/.ruby-version +1 -1
  9. data/.vscode/extensions.json +5 -0
  10. data/.vscode/settings.json +9 -0
  11. data/CHANGELOG.md +44 -4
  12. data/CONTRIBUTING.md +1 -29
  13. data/{Dockerfile → Codespace.dockerfile} +2 -2
  14. data/Gemfile.lock +5 -5
  15. data/README.md +20 -99
  16. data/Rakefile +27 -0
  17. data/Tests.dockerfile +35 -0
  18. data/assets/logo.png +0 -0
  19. data/dev.yml +1 -4
  20. data/docs/README.md +13 -0
  21. data/docs/contributors/testing.md +27 -0
  22. data/docs/users/installation.md +46 -0
  23. data/{THEMEKIT_MIGRATION.md → docs/users/migrate-from-themekit.md} +1 -1
  24. data/ext/javy/hashes/javy-arm-macos-v0.1.0.gz.sha256 +1 -0
  25. data/ext/javy/hashes/javy-x86_64-linux-v0.1.0.gz.sha256 +1 -0
  26. data/ext/javy/hashes/javy-x86_64-macos-v0.1.0.gz.sha256 +1 -0
  27. data/ext/javy/hashes/javy-x86_64-windows-v0.1.0.gz.sha256 +1 -0
  28. data/ext/javy/javy.rb +205 -0
  29. data/ext/javy/version +1 -0
  30. data/lib/project_types/extension/cli.rb +6 -3
  31. data/lib/project_types/extension/commands/build.rb +4 -8
  32. data/lib/project_types/extension/commands/create.rb +2 -5
  33. data/lib/project_types/extension/commands/extension_command.rb +1 -1
  34. data/lib/project_types/extension/features/argo_serve.rb +9 -23
  35. data/lib/project_types/extension/forms/questions/ask_template.rb +1 -5
  36. data/lib/project_types/extension/messages/messages.rb +0 -2
  37. data/lib/project_types/extension/models/development_server.rb +2 -2
  38. data/lib/project_types/extension/models/development_server_requirements.rb +2 -3
  39. data/lib/project_types/extension/models/server_config/app.rb +13 -0
  40. data/lib/project_types/extension/models/server_config/development.rb +5 -4
  41. data/lib/project_types/extension/models/server_config/development_renderer.rb +1 -1
  42. data/lib/project_types/extension/models/server_config/development_resource.rb +13 -0
  43. data/lib/project_types/extension/models/server_config/extension.rb +3 -1
  44. data/lib/project_types/extension/models/server_config/root.rb +4 -1
  45. data/lib/project_types/extension/tasks/convert_server_config.rb +65 -0
  46. data/lib/project_types/extension/tasks/ensure_resource_url.rb +39 -0
  47. data/lib/project_types/extension/tasks/merge_server_config.rb +32 -0
  48. data/lib/project_types/extension/tasks/run_extension_command.rb +11 -10
  49. data/lib/project_types/node/cli.rb +0 -16
  50. data/lib/project_types/node/forms/create.rb +5 -5
  51. data/lib/project_types/node/messages/messages.rb +2 -144
  52. data/lib/project_types/php/cli.rb +0 -11
  53. data/lib/project_types/php/forms/create.rb +5 -6
  54. data/lib/project_types/php/messages/messages.rb +2 -161
  55. data/lib/project_types/rails/cli.rb +0 -16
  56. data/lib/project_types/rails/commands/create.rb +3 -5
  57. data/lib/project_types/rails/forms/create.rb +5 -6
  58. data/lib/project_types/rails/messages/messages.rb +6 -151
  59. data/lib/project_types/script/cli.rb +8 -2
  60. data/lib/project_types/script/commands/create.rb +2 -4
  61. data/lib/project_types/script/commands/javy.rb +29 -0
  62. data/lib/project_types/script/commands/push.rb +3 -2
  63. data/lib/project_types/script/config/extension_points.yml +12 -30
  64. data/lib/project_types/script/forms/ask_app.rb +32 -0
  65. data/lib/project_types/script/forms/ask_org.rb +30 -0
  66. data/lib/project_types/script/forms/ask_script_uuid.rb +22 -0
  67. data/lib/project_types/script/forms/run_against_shopify_org.rb +14 -0
  68. data/lib/project_types/script/graphql/app_script_set.graphql +2 -2
  69. data/lib/project_types/script/layers/application/build_script.rb +0 -1
  70. data/lib/project_types/script/layers/application/connect_app.rb +73 -0
  71. data/lib/project_types/script/layers/application/create_script.rb +1 -1
  72. data/lib/project_types/script/layers/application/push_script.rb +1 -1
  73. data/lib/project_types/script/layers/domain/errors.rb +1 -4
  74. data/lib/project_types/script/layers/domain/push_package.rb +3 -3
  75. data/lib/project_types/script/layers/domain/{script_json.rb → script_config.rb} +2 -2
  76. data/lib/project_types/script/layers/domain/script_project.rb +5 -1
  77. data/lib/project_types/script/layers/infrastructure/errors.rb +36 -7
  78. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +0 -4
  79. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +0 -4
  80. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +2 -2
  81. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +104 -27
  82. data/lib/project_types/script/layers/infrastructure/script_service.rb +11 -11
  83. data/lib/project_types/script/messages/messages.rb +21 -4
  84. data/lib/project_types/script/ui/error_handler.rb +31 -21
  85. data/lib/project_types/theme/cli.rb +1 -1
  86. data/lib/project_types/theme/commands/check.rb +1 -1
  87. data/lib/project_types/theme/commands/delete.rb +1 -1
  88. data/lib/project_types/theme/commands/init.rb +1 -1
  89. data/lib/project_types/theme/commands/language_server.rb +1 -1
  90. data/lib/project_types/theme/commands/package.rb +1 -1
  91. data/lib/project_types/theme/commands/publish.rb +1 -1
  92. data/lib/project_types/theme/commands/pull.rb +4 -1
  93. data/lib/project_types/theme/commands/push.rb +5 -1
  94. data/lib/project_types/theme/commands/serve.rb +9 -3
  95. data/lib/project_types/theme/messages/messages.rb +39 -2
  96. data/lib/project_types/theme/ui/sync_progress_bar.rb +2 -2
  97. data/lib/shopify_cli/admin_api/populate_resource_command.rb +1 -1
  98. data/lib/shopify_cli/api.rb +7 -2
  99. data/lib/shopify_cli/app_type_detector.rb +24 -20
  100. data/lib/shopify_cli/command/app_sub_command.rb +10 -0
  101. data/lib/shopify_cli/command/project_command.rb +31 -0
  102. data/lib/shopify_cli/command/sub_command.rb +19 -0
  103. data/lib/shopify_cli/command.rb +7 -2
  104. data/lib/shopify_cli/commands/app/connect.rb +22 -0
  105. data/lib/shopify_cli/commands/app/create/node.rb +36 -0
  106. data/lib/shopify_cli/commands/app/create/php.rb +36 -0
  107. data/lib/shopify_cli/commands/app/create/rails.rb +38 -0
  108. data/lib/shopify_cli/commands/app/create.rb +28 -0
  109. data/lib/shopify_cli/commands/app/deploy.rb +49 -0
  110. data/lib/shopify_cli/commands/app/open.rb +19 -0
  111. data/lib/shopify_cli/commands/app/serve.rb +49 -0
  112. data/lib/shopify_cli/commands/app/tunnel.rb +43 -0
  113. data/lib/shopify_cli/commands/app.rb +29 -0
  114. data/lib/shopify_cli/commands/config.rb +2 -2
  115. data/lib/shopify_cli/commands.rb +1 -0
  116. data/lib/shopify_cli/constants.rb +7 -0
  117. data/lib/shopify_cli/context.rb +10 -0
  118. data/lib/shopify_cli/environment.rb +4 -0
  119. data/lib/shopify_cli/exception_reporter.rb +3 -4
  120. data/lib/shopify_cli/git.rb +14 -1
  121. data/lib/shopify_cli/github/issue_url_generator.rb +19 -0
  122. data/lib/shopify_cli/github.rb +5 -0
  123. data/lib/shopify_cli/identity_auth.rb +18 -0
  124. data/lib/shopify_cli/messages/messages.rb +254 -9
  125. data/lib/shopify_cli/partners_api.rb +1 -8
  126. data/lib/shopify_cli/project.rb +5 -1
  127. data/lib/shopify_cli/project_commands.rb +1 -1
  128. data/lib/shopify_cli/services/app/connect_service.rb +25 -0
  129. data/lib/shopify_cli/services/app/create/node_service.rb +155 -0
  130. data/lib/shopify_cli/services/app/create/php_service.rb +152 -0
  131. data/lib/shopify_cli/services/app/create/rails_service.rb +215 -0
  132. data/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +101 -0
  133. data/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +135 -0
  134. data/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +120 -0
  135. data/lib/shopify_cli/services/app/open_service.rb +19 -0
  136. data/lib/shopify_cli/services/app/serve/node_service.rb +42 -0
  137. data/lib/shopify_cli/services/app/serve/php_service.rb +46 -0
  138. data/lib/shopify_cli/services/app/serve/rails_service.rb +48 -0
  139. data/lib/shopify_cli/services/app/tunnel/auth_service.rb +21 -0
  140. data/lib/shopify_cli/services/app/tunnel/start_service.rb +20 -0
  141. data/lib/shopify_cli/services/app/tunnel/stop_service.rb +20 -0
  142. data/lib/shopify_cli/services.rb +31 -0
  143. data/lib/shopify_cli/tasks/ensure_authenticated.rb +9 -3
  144. data/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +73 -0
  145. data/lib/shopify_cli/theme/dev_server/hot-reload.js +25 -9
  146. data/lib/shopify_cli/theme/dev_server/local_assets.rb +1 -1
  147. data/lib/shopify_cli/theme/dev_server.rb +37 -18
  148. data/lib/shopify_cli/theme/syncer/error_reporter.rb +45 -0
  149. data/lib/shopify_cli/theme/syncer/operation.rb +56 -0
  150. data/lib/shopify_cli/theme/syncer/standard_reporter.rb +32 -0
  151. data/lib/shopify_cli/theme/syncer.rb +40 -39
  152. data/lib/shopify_cli/theme/theme.rb +31 -19
  153. data/lib/shopify_cli/tunnel.rb +26 -22
  154. data/lib/shopify_cli/version.rb +1 -1
  155. data/lib/shopify_cli.rb +1 -2
  156. data/shopify-cli.gemspec +1 -1
  157. data/shopify-dev +18 -0
  158. data/utilities/constants.rb +7 -0
  159. data/utilities/docker/container.rb +10 -3
  160. data/utilities/docker.rb +2 -2
  161. data/utilities/utilities.rb +1 -0
  162. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +1 -1
  163. metadata +66 -50
  164. data/docs/_config.yml +0 -2
  165. data/docs/app/node/commands/index.md +0 -4
  166. data/docs/app/node/index.md +0 -4
  167. data/docs/app/rails/commands/index.md +0 -4
  168. data/docs/app/rails/index.md +0 -4
  169. data/docs/core/index.md +0 -4
  170. data/docs/getting-started/index.md +0 -4
  171. data/docs/getting-started/install/index.md +0 -4
  172. data/docs/getting-started/migrate/index.md +0 -4
  173. data/docs/getting-started/uninstall/index.md +0 -4
  174. data/docs/getting-started/upgrade/index.md +0 -4
  175. data/docs/help/start-app/index.md +0 -4
  176. data/docs/index.md +0 -4
  177. data/install.sh +0 -7
  178. data/lib/project_types/extension/tasks/converters/server_config_converter.rb +0 -30
  179. data/lib/project_types/extension/tasks/load_server_config.rb +0 -28
  180. data/lib/project_types/node/commands/connect.rb +0 -21
  181. data/lib/project_types/node/commands/create.rb +0 -125
  182. data/lib/project_types/node/commands/deploy/heroku.rb +0 -96
  183. data/lib/project_types/node/commands/deploy.rb +0 -32
  184. data/lib/project_types/node/commands/generate.rb +0 -22
  185. data/lib/project_types/node/commands/open.rb +0 -18
  186. data/lib/project_types/node/commands/serve.rb +0 -45
  187. data/lib/project_types/node/commands/tunnel.rb +0 -41
  188. data/lib/project_types/php/commands/connect.rb +0 -19
  189. data/lib/project_types/php/commands/create.rb +0 -143
  190. data/lib/project_types/php/commands/deploy/heroku.rb +0 -129
  191. data/lib/project_types/php/commands/deploy.rb +0 -32
  192. data/lib/project_types/php/commands/open.rb +0 -16
  193. data/lib/project_types/php/commands/serve.rb +0 -48
  194. data/lib/project_types/php/commands/tunnel.rb +0 -37
  195. data/lib/project_types/rails/commands/connect.rb +0 -21
  196. data/lib/project_types/rails/commands/deploy/heroku.rb +0 -115
  197. data/lib/project_types/rails/commands/deploy.rb +0 -32
  198. data/lib/project_types/rails/commands/generate/webhook.rb +0 -42
  199. data/lib/project_types/rails/commands/generate.rb +0 -60
  200. data/lib/project_types/rails/commands/open.rb +0 -18
  201. data/lib/project_types/rails/commands/serve.rb +0 -51
  202. data/lib/project_types/rails/commands/tunnel.rb +0 -41
  203. data/lib/project_types/script/tasks/ensure_env.rb +0 -106
  204. data/lib/shopify_cli/sub_command.rb +0 -17
  205. data/shopify.fish +0 -12
  206. 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,15 +9,20 @@ 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
 
19
20
  # define/autoload project specific Forms
20
21
  module Forms
22
+ autoload :AskOrg, Project.project_filepath("forms/ask_org")
23
+ autoload :AskApp, Project.project_filepath("forms/ask_app")
24
+ autoload :AskScriptUuid, Project.project_filepath("forms/ask_script_uuid")
25
+ autoload :RunAgainstShopifyOrg, Project.project_filepath("forms/run_against_shopify_org")
21
26
  autoload :Create, Project.project_filepath("forms/create")
22
27
  autoload :ScriptForm, Project.project_filepath("forms/script_form")
23
28
  end
@@ -29,6 +34,7 @@ module Script
29
34
  module Layers
30
35
  module Application
31
36
  autoload :BuildScript, Project.project_filepath("layers/application/build_script")
37
+ autoload :ConnectApp, Project.project_filepath("layers/application/connect_app")
32
38
  autoload :CreateScript, Project.project_filepath("layers/application/create_script")
33
39
  autoload :PushScript, Project.project_filepath("layers/application/push_script")
34
40
  autoload :ExtensionPoints, Project.project_filepath("layers/application/extension_points")
@@ -40,7 +46,7 @@ module Script
40
46
  autoload :PushPackage, Project.project_filepath("layers/domain/push_package")
41
47
  autoload :Metadata, Project.project_filepath("layers/domain/metadata")
42
48
  autoload :ExtensionPoint, Project.project_filepath("layers/domain/extension_point")
43
- autoload :ScriptJson, Project.project_filepath("layers/domain/script_json")
49
+ autoload :ScriptConfig, Project.project_filepath("layers/domain/script_config")
44
50
  autoload :ScriptProject, Project.project_filepath("layers/domain/script_project")
45
51
  end
46
52
 
@@ -2,10 +2,8 @@
2
2
 
3
3
  module Script
4
4
  class Command
5
- class Create < ShopifyCLI::SubCommand
6
- unless ShopifyCLI::Environment.acceptance_test?
7
- prerequisite_task :ensure_authenticated
8
- end
5
+ class Create < ShopifyCLI::Command::SubCommand
6
+ prerequisite_task :ensure_authenticated
9
7
 
10
8
  options do |parser, flags|
11
9
  parser.on("--name=NAME") { |name| flags[:name] = name }
@@ -0,0 +1,29 @@
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
+ options do |parser, flags|
11
+ parser.on("--in=IN") { |in_file| flags[:in_file] = in_file }
12
+ parser.on("--out=OUT") { |out_file| flags[:out_file] = out_file }
13
+ end
14
+
15
+ def call(*)
16
+ source = options.flags[:in_file]
17
+ dest = options.flags[:out_file]
18
+
19
+ @ctx.abort(@ctx.message("script.javy.errors.invalid_arguments", ShopifyCLI::TOOL_NAME)) unless source
20
+
21
+ ::Javy.build(source: source, dest: dest).unwrap { |e| @ctx.abort(e.message) }
22
+ end
23
+
24
+ def self.help
25
+ ShopifyCLI::Context.message("script.javy.help", ShopifyCLI::TOOL_NAME)
26
+ end
27
+ end
28
+ end
29
+ 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|
@@ -10,7 +10,8 @@ module Script
10
10
  end
11
11
 
12
12
  def call(_args, _name)
13
- fresh_env = Tasks::EnsureEnv.call(@ctx)
13
+ fresh_env = Layers::Application::ConnectApp.call(ctx: @ctx)
14
+
14
15
  force = options.flags.key?(:force) || !!fresh_env
15
16
 
16
17
  api_key = Layers::Infrastructure::ScriptProjectRepository.new(ctx: @ctx).get.api_key
@@ -1,29 +1,3 @@
1
- discount:
2
- deprecated: true
3
- libraries:
4
- assemblyscript:
5
- package: "@shopify/extension-point-as-discount"
6
- unit_limit_per_order:
7
- beta: true
8
- libraries:
9
- assemblyscript:
10
- package: "@shopify/extension-point-as-unit-limit-per-order"
11
- payment_filter:
12
- deprecated: true
13
- libraries:
14
- assemblyscript:
15
- package: "@shopify/extension-point-as-payment-filter"
16
- shipping_filter:
17
- deprecated: true
18
- libraries:
19
- assemblyscript:
20
- package: "@shopify/extension-point-as-shipping-filter"
21
- tax_filter:
22
- beta: true
23
- libraries:
24
- assemblyscript:
25
- repo: "https://github.com/Shopify/extension-points.git"
26
- package: "@shopify/extension-point-as-tax-filter"
27
1
  payment_methods:
28
2
  domain: 'checkout'
29
3
  libraries:
@@ -32,7 +6,7 @@ payment_methods:
32
6
  package: "@shopify/scripts-checkout-apis"
33
7
  typescript:
34
8
  beta: true
35
- package: "@shopify/scripts-checkout-apis-temp"
9
+ package: "@shopify/scripts-checkout-apis"
36
10
  repo: "https://github.com/Shopify/scripts-apis-examples"
37
11
  shipping_methods:
38
12
  domain: 'checkout'
@@ -42,13 +16,21 @@ shipping_methods:
42
16
  package: "@shopify/scripts-checkout-apis"
43
17
  typescript:
44
18
  beta: true
45
- package: "@shopify/scripts-checkout-apis-temp"
19
+ package: "@shopify/scripts-checkout-apis"
20
+ repo: "https://github.com/Shopify/scripts-apis-examples"
21
+ merchandise_discount_types:
22
+ beta: true
23
+ domain: 'discounts'
24
+ libraries:
25
+ typescript:
26
+ beta: true
27
+ package: "@shopify/scripts-discounts-apis"
46
28
  repo: "https://github.com/Shopify/scripts-apis-examples"
47
- discount_types:
29
+ delivery_discount_types:
48
30
  beta: true
49
31
  domain: 'discounts'
50
32
  libraries:
51
33
  typescript:
52
34
  beta: true
53
- package: "@shopify/scripts-discount-apis"
35
+ package: "@shopify/scripts-discounts-apis"
54
36
  repo: "https://github.com/Shopify/scripts-apis-examples"
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Script
4
+ module Forms
5
+ class AskApp < ShopifyCLI::Form
6
+ attr_reader :app
7
+
8
+ def ask
9
+ apps = @xargs.fetch(:apps)
10
+
11
+ unless @xargs[:acting_as_shopify_organization]
12
+ apps = apps.select { |app| app["appType"] == "custom" }
13
+ end
14
+
15
+ raise Errors::NoExistingAppsError if apps.empty?
16
+
17
+ @app =
18
+ if apps.count > 1
19
+ CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.app_select")) do |handler|
20
+ apps.each do |app|
21
+ handler.option(app["title"]) { app }
22
+ end
23
+ end
24
+ else
25
+ apps.first.tap do |app|
26
+ ctx.puts(ctx.message("script.application.ensure_env.app", app["title"]))
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Script
4
+ module Forms
5
+ class AskOrg < ShopifyCLI::Form
6
+ attr_reader :org
7
+
8
+ BUSINESS_NAME = "businessName"
9
+ ID = "id"
10
+
11
+ def ask
12
+ orgs = @xargs
13
+ @org =
14
+ if orgs.count == 1
15
+ orgs.first.tap do |org|
16
+ ctx.puts(ctx.message("script.application.ensure_env.organization", org[BUSINESS_NAME], org[ID]))
17
+ end
18
+ elsif orgs.count > 0
19
+ CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.organization_select")) do |handler|
20
+ orgs.each do |org|
21
+ handler.option("#{org[BUSINESS_NAME]} (#{org[ID]})") { org }
22
+ end
23
+ end
24
+ else
25
+ raise Errors::NoExistingOrganizationsError
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Script
4
+ module Forms
5
+ class AskScriptUuid < ShopifyCLI::Form
6
+ attr_reader :uuid
7
+ def ask
8
+ scripts = @xargs
9
+
10
+ return if scripts.empty? ||
11
+ !CLI::UI::Prompt.confirm(ctx.message("script.application.ensure_env.ask_connect_to_existing_script"))
12
+
13
+ @uuid =
14
+ CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.ask_which_script_to_connect_to")) do |handler|
15
+ scripts.each do |script|
16
+ handler.option("#{script["title"]} (#{script["uuid"]})") { script["uuid"] }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Script
4
+ module Forms
5
+ class RunAgainstShopifyOrg < ShopifyCLI::Form
6
+ attr_reader :response
7
+ def ask
8
+ @ctx.puts(@ctx.message("core.tasks.select_org_and_shop.identified_as_shopify"))
9
+ message = @ctx.message("core.tasks.select_org_and_shop.first_party")
10
+ @response = CLI::UI::Prompt.confirm(message, default: false)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -6,7 +6,7 @@ mutation AppScriptSet(
6
6
  $force: Boolean,
7
7
  $schemaMajorVersion: String,
8
8
  $schemaMinorVersion: String,
9
- $scriptJsonVersion: String!,
9
+ $scriptConfigVersion: String!,
10
10
  $configurationUi: Boolean!,
11
11
  $configurationDefinition: String!,
12
12
  $moduleUploadUrl: String!,
@@ -20,7 +20,7 @@ mutation AppScriptSet(
20
20
  force: $force
21
21
  schemaMajorVersion: $schemaMajorVersion
22
22
  schemaMinorVersion: $schemaMinorVersion,
23
- scriptJsonVersion: $scriptJsonVersion,
23
+ scriptConfigVersion: $scriptConfigVersion,
24
24
  configurationUi: $configurationUi,
25
25
  configurationDefinition: $configurationDefinition,
26
26
  moduleUploadUrl: $moduleUploadUrl,
@@ -23,7 +23,6 @@ module Script
23
23
  ctx.puts("\n{{red:#{e.message}}}")
24
24
  end
25
25
  errors = [
26
- Infrastructure::Errors::InvalidBuildScriptError,
27
26
  Infrastructure::Errors::BuildScriptNotFoundError,
28
27
  Infrastructure::Errors::WebAssemblyBinaryNotFoundError,
29
28
  ]
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "shopify_cli"
4
+
5
+ module Script
6
+ module Layers
7
+ module Application
8
+ class ConnectApp
9
+ class << self
10
+ def call(ctx:)
11
+ script_project_repo = Layers::Infrastructure::ScriptProjectRepository.new(ctx: ctx)
12
+ script_project = script_project_repo.get
13
+ return false if script_project.env_valid?
14
+
15
+ if ShopifyCLI::Shopifolk.check && Forms::RunAgainstShopifyOrg.ask(ctx, nil, nil).response
16
+ ShopifyCLI::Shopifolk.act_as_shopify_organization
17
+ end
18
+
19
+ org =
20
+ if partner_proxy_bypass
21
+ stubbed_org
22
+ else
23
+ orgs = ShopifyCLI::PartnersAPI::Organizations.fetch_with_app(ctx)
24
+ Forms::AskOrg.ask(ctx, orgs, nil).org
25
+ end
26
+
27
+ app = Forms::AskApp.ask(
28
+ ctx,
29
+ {
30
+ apps: org["apps"],
31
+ acting_as_shopify_organization: ShopifyCLI::Shopifolk.acting_as_shopify_organization?,
32
+ },
33
+ nil
34
+ ).app
35
+
36
+ script_service = Layers::Infrastructure::ServiceLocator.script_service(ctx: ctx, api_key: app["apiKey"])
37
+ extension_point_type = script_project.extension_point_type
38
+ scripts = script_service.get_app_scripts(extension_point_type: extension_point_type)
39
+
40
+ uuid = Forms::AskScriptUuid.ask(ctx, scripts, nil).uuid
41
+
42
+ script_project_repo.create_env(
43
+ api_key: app["apiKey"],
44
+ secret: app["apiSecretKeys"].first["secret"],
45
+ uuid: uuid
46
+ )
47
+
48
+ true
49
+ end
50
+
51
+ private
52
+
53
+ def partner_proxy_bypass
54
+ !ENV["BYPASS_PARTNERS_PROXY"].nil?
55
+ end
56
+
57
+ def stubbed_org
58
+ {
59
+ "apps" => [
60
+ {
61
+ "appType" => "custom",
62
+ "apiKey" => "stubbed-api-key",
63
+ "apiSecretKeys" => [{ "secret" => "stubbed-api-secret" }],
64
+ "title" => "Fake App (Not connected to Partners)",
65
+ },
66
+ ],
67
+ }
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -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)
39
+ script_project_repo.update_script_config(title: script_name)
40
40
  project
41
41
  end
42
42
  end
@@ -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