shopify-cli 2.6.5 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) 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 +42 -4
  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 +4 -8
  26. data/lib/project_types/extension/commands/create.rb +3 -5
  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 -2
  33. data/lib/project_types/extension/models/development_server.rb +2 -2
  34. data/lib/project_types/extension/models/development_server_requirements.rb +2 -3
  35. data/lib/project_types/extension/models/server_config/app.rb +13 -0
  36. data/lib/project_types/extension/models/server_config/development.rb +5 -4
  37. data/lib/project_types/extension/models/server_config/development_renderer.rb +1 -1
  38. data/lib/project_types/extension/models/server_config/development_resource.rb +13 -0
  39. data/lib/project_types/extension/models/server_config/extension.rb +4 -0
  40. data/lib/project_types/extension/models/server_config/root.rb +4 -1
  41. data/lib/project_types/extension/tasks/convert_server_config.rb +65 -0
  42. data/lib/project_types/extension/tasks/ensure_resource_url.rb +39 -0
  43. data/lib/project_types/extension/tasks/find_package_from_json.rb +37 -0
  44. data/lib/project_types/extension/tasks/merge_server_config.rb +32 -0
  45. data/lib/project_types/extension/tasks/run_extension_command.rb +11 -10
  46. data/lib/project_types/node/cli.rb +0 -16
  47. data/lib/project_types/node/forms/create.rb +5 -5
  48. data/lib/project_types/node/messages/messages.rb +2 -144
  49. data/lib/project_types/php/cli.rb +0 -11
  50. data/lib/project_types/php/forms/create.rb +5 -6
  51. data/lib/project_types/php/messages/messages.rb +2 -161
  52. data/lib/project_types/rails/cli.rb +0 -16
  53. data/lib/project_types/rails/commands/create.rb +43 -16
  54. data/lib/project_types/rails/forms/create.rb +5 -7
  55. data/lib/project_types/rails/messages/messages.rb +6 -151
  56. data/lib/project_types/script/cli.rb +7 -1
  57. data/lib/project_types/script/commands/create.rb +3 -8
  58. data/lib/project_types/script/commands/javy.rb +29 -0
  59. data/lib/project_types/script/commands/push.rb +3 -2
  60. data/lib/project_types/script/config/extension_points.yml +3 -26
  61. data/lib/project_types/script/errors.rb +0 -18
  62. data/lib/project_types/script/forms/ask_app.rb +32 -0
  63. data/lib/project_types/script/forms/ask_org.rb +30 -0
  64. data/lib/project_types/script/forms/ask_script_uuid.rb +22 -0
  65. data/lib/project_types/script/forms/run_against_shopify_org.rb +14 -0
  66. data/lib/project_types/script/layers/application/build_script.rb +0 -1
  67. data/lib/project_types/script/layers/application/connect_app.rb +73 -0
  68. data/lib/project_types/script/layers/application/create_script.rb +2 -2
  69. data/lib/project_types/script/layers/domain/script_json.rb +1 -1
  70. data/lib/project_types/script/layers/domain/script_project.rb +4 -0
  71. data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -4
  72. data/lib/project_types/script/layers/infrastructure/errors.rb +8 -4
  73. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +1 -5
  74. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +25 -4
  75. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +3 -4
  76. data/lib/project_types/script/layers/infrastructure/script_service.rb +1 -1
  77. data/lib/project_types/script/messages/messages.rb +16 -20
  78. data/lib/project_types/script/ui/error_handler.rb +1 -32
  79. data/lib/project_types/theme/cli.rb +1 -1
  80. data/lib/project_types/theme/commands/check.rb +1 -1
  81. data/lib/project_types/theme/commands/delete.rb +1 -1
  82. data/lib/project_types/theme/commands/init.rb +1 -1
  83. data/lib/project_types/theme/commands/language_server.rb +1 -1
  84. data/lib/project_types/theme/commands/package.rb +1 -1
  85. data/lib/project_types/theme/commands/publish.rb +1 -1
  86. data/lib/project_types/theme/commands/pull.rb +4 -1
  87. data/lib/project_types/theme/commands/push.rb +7 -2
  88. data/lib/project_types/theme/commands/serve.rb +9 -2
  89. data/lib/project_types/theme/messages/messages.rb +39 -1
  90. data/lib/project_types/theme/ui/sync_progress_bar.rb +2 -2
  91. data/lib/shopify_cli/admin_api/populate_resource_command.rb +1 -1
  92. data/lib/shopify_cli/api.rb +7 -2
  93. data/lib/shopify_cli/app_type_detector.rb +24 -20
  94. data/lib/shopify_cli/command/app_sub_command.rb +10 -0
  95. data/lib/shopify_cli/command/project_command.rb +31 -0
  96. data/lib/shopify_cli/command/sub_command.rb +19 -0
  97. data/lib/shopify_cli/command.rb +7 -2
  98. data/lib/shopify_cli/commands/app/connect.rb +22 -0
  99. data/lib/shopify_cli/commands/app/create/node.rb +36 -0
  100. data/lib/shopify_cli/commands/app/create/php.rb +36 -0
  101. data/lib/shopify_cli/commands/app/create/rails.rb +38 -0
  102. data/lib/shopify_cli/commands/app/create.rb +28 -0
  103. data/lib/shopify_cli/commands/app/deploy.rb +49 -0
  104. data/lib/shopify_cli/commands/app/open.rb +19 -0
  105. data/lib/shopify_cli/commands/app/serve.rb +49 -0
  106. data/lib/shopify_cli/commands/app/tunnel.rb +43 -0
  107. data/lib/shopify_cli/commands/app.rb +29 -0
  108. data/lib/shopify_cli/commands/config.rb +2 -2
  109. data/lib/shopify_cli/commands.rb +1 -0
  110. data/lib/shopify_cli/constants.rb +7 -0
  111. data/lib/shopify_cli/context.rb +9 -0
  112. data/lib/shopify_cli/environment.rb +4 -0
  113. data/lib/shopify_cli/exception_reporter.rb +8 -6
  114. data/lib/shopify_cli/git.rb +12 -1
  115. data/lib/shopify_cli/github/issue_url_generator.rb +19 -0
  116. data/lib/shopify_cli/github.rb +5 -0
  117. data/lib/shopify_cli/identity_auth.rb +18 -0
  118. data/lib/shopify_cli/messages/messages.rb +254 -9
  119. data/lib/shopify_cli/migrator.rb +9 -11
  120. data/lib/shopify_cli/partners_api.rb +1 -8
  121. data/lib/shopify_cli/project.rb +5 -1
  122. data/lib/shopify_cli/project_commands.rb +1 -1
  123. data/lib/shopify_cli/services/app/connect_service.rb +25 -0
  124. data/lib/shopify_cli/services/app/create/node_service.rb +155 -0
  125. data/lib/shopify_cli/services/app/create/php_service.rb +152 -0
  126. data/lib/shopify_cli/services/app/create/rails_service.rb +215 -0
  127. data/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +101 -0
  128. data/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +135 -0
  129. data/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +120 -0
  130. data/lib/shopify_cli/services/app/open_service.rb +19 -0
  131. data/lib/shopify_cli/services/app/serve/node_service.rb +42 -0
  132. data/lib/shopify_cli/services/app/serve/php_service.rb +46 -0
  133. data/lib/shopify_cli/services/app/serve/rails_service.rb +48 -0
  134. data/lib/shopify_cli/services/app/tunnel/auth_service.rb +21 -0
  135. data/lib/shopify_cli/services/app/tunnel/start_service.rb +20 -0
  136. data/lib/shopify_cli/services/app/tunnel/stop_service.rb +20 -0
  137. data/lib/shopify_cli/services.rb +31 -0
  138. data/lib/shopify_cli/tasks/ensure_authenticated.rb +9 -3
  139. data/lib/shopify_cli/theme/dev_server/local_assets.rb +1 -1
  140. data/lib/shopify_cli/theme/dev_server.rb +35 -17
  141. data/lib/shopify_cli/theme/syncer/error_reporter.rb +45 -0
  142. data/lib/shopify_cli/theme/syncer/operation.rb +56 -0
  143. data/lib/shopify_cli/theme/syncer/standard_reporter.rb +32 -0
  144. data/lib/shopify_cli/theme/syncer.rb +40 -39
  145. data/lib/shopify_cli/theme/theme.rb +31 -19
  146. data/lib/shopify_cli/tunnel.rb +25 -22
  147. data/lib/shopify_cli/version.rb +1 -1
  148. data/lib/shopify_cli.rb +1 -2
  149. data/shopify-cli.gemspec +2 -6
  150. data/shopify-dev +18 -0
  151. data/utilities/constants.rb +7 -0
  152. data/utilities/docker/container.rb +30 -2
  153. data/utilities/docker.rb +3 -2
  154. data/utilities/utilities.rb +1 -0
  155. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +1 -1
  156. metadata +64 -54
  157. data/docs/_config.yml +0 -2
  158. data/docs/app/node/commands/index.md +0 -4
  159. data/docs/app/node/index.md +0 -4
  160. data/docs/app/rails/commands/index.md +0 -4
  161. data/docs/app/rails/index.md +0 -4
  162. data/docs/core/index.md +0 -4
  163. data/docs/getting-started/index.md +0 -4
  164. data/docs/getting-started/install/index.md +0 -4
  165. data/docs/getting-started/migrate/index.md +0 -4
  166. data/docs/getting-started/uninstall/index.md +0 -4
  167. data/docs/getting-started/upgrade/index.md +0 -4
  168. data/docs/help/start-app/index.md +0 -4
  169. data/docs/index.md +0 -4
  170. data/ext/shopify-cli/extconf.rb +0 -60
  171. data/install.sh +0 -7
  172. data/lib/project_types/extension/tasks/converters/server_config_converter.rb +0 -31
  173. data/lib/project_types/extension/tasks/load_server_config.rb +0 -23
  174. data/lib/project_types/node/commands/connect.rb +0 -21
  175. data/lib/project_types/node/commands/create.rb +0 -125
  176. data/lib/project_types/node/commands/deploy/heroku.rb +0 -96
  177. data/lib/project_types/node/commands/deploy.rb +0 -32
  178. data/lib/project_types/node/commands/generate.rb +0 -22
  179. data/lib/project_types/node/commands/open.rb +0 -18
  180. data/lib/project_types/node/commands/serve.rb +0 -45
  181. data/lib/project_types/node/commands/tunnel.rb +0 -41
  182. data/lib/project_types/php/commands/connect.rb +0 -19
  183. data/lib/project_types/php/commands/create.rb +0 -143
  184. data/lib/project_types/php/commands/deploy/heroku.rb +0 -129
  185. data/lib/project_types/php/commands/deploy.rb +0 -32
  186. data/lib/project_types/php/commands/open.rb +0 -16
  187. data/lib/project_types/php/commands/serve.rb +0 -48
  188. data/lib/project_types/php/commands/tunnel.rb +0 -37
  189. data/lib/project_types/rails/commands/connect.rb +0 -21
  190. data/lib/project_types/rails/commands/deploy/heroku.rb +0 -115
  191. data/lib/project_types/rails/commands/deploy.rb +0 -32
  192. data/lib/project_types/rails/commands/generate/webhook.rb +0 -42
  193. data/lib/project_types/rails/commands/generate.rb +0 -60
  194. data/lib/project_types/rails/commands/open.rb +0 -18
  195. data/lib/project_types/rails/commands/serve.rb +0 -51
  196. data/lib/project_types/rails/commands/tunnel.rb +0 -41
  197. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -0
  198. data/lib/project_types/script/tasks/ensure_env.rb +0 -106
  199. data/lib/shopify_cli/sub_command.rb +0 -17
  200. data/shopify.fish +0 -12
  201. data/shopify.sh +0 -11
@@ -8,28 +8,272 @@ module ShopifyCLI
8
8
  info: {
9
9
  created: "{{v}} {{green:%s}} was created in the organization's Partner Dashboard {{underline:%s}}",
10
10
  serve: "{{*}} Change directories to your new project folder {{green:%s}} and run "\
11
- "{{command:%s %s serve}} to start a local server",
11
+ "{{command:%s app serve}} to start a local server",
12
12
  install: "{{*}} Then, visit {{underline:%s/test}} to install {{green:%s}} on your Dev Store",
13
13
  },
14
14
  },
15
15
  },
16
16
  core: {
17
17
  app: {
18
+ help: <<~HELP,
19
+ Suite of commands for developing apps. See {{command:%1$s app <command> --help}} for usage of each command.
20
+ Usage: {{command:%1$s app [ %2$s ]}}
21
+ HELP
22
+ error: {
23
+ type_not_found: <<~MESSAGE,
24
+ Couldn't detect the app type in directory %s. We currently support Rails, PHP, and NodeJS apps.
25
+ MESSAGE
26
+ missing_shopify_cli_yml: <<~MESSAGE,
27
+ Couldn't find a #{Constants::Files::SHOPIFY_CLI_YML} file in the directory %s to determine the app type.
28
+ MESSAGE
29
+ invalid_project_type: <<~MESSAGE,
30
+ The project type %s doesn't represent an app.
31
+ MESSAGE
32
+ },
33
+ create: {
34
+ type_required_error: "",
35
+ invalid_type: "The type %s is not supported. The only supported types are"\
36
+ " {{command:[ rails | node | php ]}}",
37
+ help: <<~HELP,
38
+ {{command:%s app create}}: Creates a ruby on rails app.
39
+ Usage: {{command:%s app create [ rails | node | php ]}}
40
+ HELP
41
+ rails: {
42
+ help: <<~HELP,
43
+ {{command:%s app create rails}}: Creates a ruby on rails app.
44
+ Usage: {{command:%s app create rails}}
45
+ Options:
46
+ {{command:--name=NAME}} App name. Any string.
47
+ {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization.
48
+ {{command:--store-domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store.
49
+ {{command:--db=DB}} Database type. Must be one of: mysql, postgresql, sqlite3, oracle, frontbase, ibm_db, sqlserver, jdbcmysql, jdbcsqlite3, jdbcpostgresql, jdbc.
50
+ {{command:--rails-opts=RAILSOPTS}} Additional options. Must be string containing one or more valid Rails options, separated by spaces.
51
+ HELP
52
+
53
+ error: {
54
+ invalid_ruby_version: "This project requires a Ruby version ~> 2.5 or Ruby 3.0.",
55
+ dir_exists: "Project directory %s already exists. Please use a different name.",
56
+ install_failure: "Error installing %s gem",
57
+ node_required: "node is required to create a rails project. Download at https://nodejs.org/en/download.",
58
+ node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \
59
+ "per the instructions at https://nodejs.org/en.",
60
+ yarn_required: "yarn is required to create a rails project. Download at " \
61
+ "https://classic.yarnpkg.com/en/docs/install.",
62
+ yarn_version_failure: "Failed to get the current yarn version. Please make sure it is " \
63
+ "installed as per the instructions at https://classic.yarnpkg.com/en/docs/install.",
64
+ },
65
+
66
+ info: {
67
+ open_new_shell: "{{*}} {{yellow:After installing %s, please open a new Command Prompt or PowerShell " \
68
+ "window to continue.}}",
69
+ },
70
+ installing_bundler: "Installing bundler…",
71
+ generating_app: "Generating new rails app project in %s…",
72
+ adding_shopify_gem: "{{v}} Adding shopify_app gem…",
73
+ node_version: "node %s",
74
+ yarn_version: "yarn %s",
75
+ running_bundle_install: "Running bundle install…",
76
+ running_generator: "Running shopify_app generator…",
77
+ running_migrations: "Running migrations…",
78
+ running_webpacker_install: "Running webpacker:install…",
79
+ },
80
+ node: {
81
+ help: <<~HELP,
82
+ {{command:%s app create node}}: Creates an embedded nodejs app.
83
+ Usage: {{command:%s app create node}}
84
+ Options:
85
+ {{command:--name=NAME}} App name. Any string.
86
+ {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization.
87
+ {{command:--store-domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store.
88
+ HELP
89
+ error: {
90
+ node_required: "node is required to create an app project. Download at https://nodejs.org/en/download.",
91
+ node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \
92
+ "per the instructions at https://nodejs.org/en.",
93
+ npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.",
94
+ npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \
95
+ "the instructions at https://www.npmjs.com/get-npm.",
96
+ },
97
+ node_version: "node %s",
98
+ npm_version: "npm %s",
99
+ },
100
+ php: {
101
+ help: <<~HELP,
102
+ {{command:%s app create php}}: Creates an embedded PHP app.
103
+ Usage: {{command:%s app create php}}
104
+ Options:
105
+ {{command:--name=NAME}} App name. Any string.
106
+ {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization.
107
+ {{command:--store-domain=MYSHOPIFYDOMAIN}} Development store URL. Must be an existing development store.
108
+ {{command:--type=APPTYPE}} Whether this app is public or custom.
109
+ {{command:--verbose}} Output verbose information when installing dependencies.
110
+ HELP
111
+
112
+ error: {
113
+ php_required: <<~VERSION,
114
+ PHP is required to create an app project. For installation instructions, visit:
115
+ {{underline:https://www.php.net/manual/en/install.php}}
116
+ VERSION
117
+ php_version_failure: <<~VERSION,
118
+ Failed to get the current PHP version. Please make sure it is installed as per the instructions at:
119
+ {{underline:https://www.php.net/manual/en/install.php.}}
120
+ VERSION
121
+ php_version_too_low: "Your PHP version is too low. Please use version %s or higher.",
122
+ composer_required: <<~COMPOSER,
123
+ Composer is required to create an app project. Download at:
124
+ {{underline:https://getcomposer.org/download/}}
125
+ COMPOSER
126
+ npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.",
127
+ npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \
128
+ "the instructions at https://www.npmjs.com/get-npm.",
129
+ app_setup: "Failed to set up the app",
130
+ },
131
+
132
+ php_version: "PHP %s",
133
+ npm_version: "npm %s",
134
+ app_setting_up: "Setting up app…",
135
+ app_set_up: "App is now set up",
136
+ },
137
+ },
138
+ deploy: {
139
+ help: <<~HELP,
140
+ Deploy the current app to a hosting service. Heroku ({{underline:https://www.heroku.com}}) is currently the only option, but more will be added in the future.
141
+ Usage: {{command:%s app deploy [ heroku ]}}
142
+ HELP
143
+ extended_help: <<~HELP,
144
+ {{bold:Subcommands:}}
145
+ {{cyan:heroku}}: Deploys the current app to Heroku.
146
+ Usage: {{command:%s app deploy heroku}}
147
+ HELP
148
+ error: {
149
+ missing_platform: <<~MESSAGE,
150
+ The platform argument is missing.
151
+ Usage: {{command:%s app deploy [ heroku ]}}
152
+ MESSAGE
153
+ invalid_platform: <<~MESSAGE,
154
+ The platform argument passed {{command:%s}} is not supported.
155
+ Usage: {{command:%s app deploy [ heroku ]}}
156
+ MESSAGE
157
+ },
158
+ heroku: {
159
+ downloading: "Downloading Heroku CLI…",
160
+ downloaded: "Downloaded Heroku CLI",
161
+ installing: "Installing Heroku CLI…",
162
+ installing_windows: "Running Heroku CLI install wizard…",
163
+ installed: "Installed Heroku CLI",
164
+ authenticated_with_account: "{{v}} Authenticated with Heroku as {{green:%s}}",
165
+ authenticating: "Authenticating with Heroku…",
166
+ authenticated: "{{v}} Authenticated with Heroku",
167
+ deploying: "Deploying to Heroku…",
168
+ deployed: "{{v}} Deployed to Heroku",
169
+ php: {
170
+ post_deploy: <<~DEPLOYED,
171
+ {{v}} Deployed to Heroku, you can access your app at {{green:%s}}
172
+
173
+ If you're deploying this app for the first time, make sure to set up your database and your app's environment at {{bold:App dashboard -> Settings -> Config Vars}}.
174
+
175
+ When setting your config vars, don't forget to set up your database and the appropriate Laravel values for it, particularly {{bold:DB_CONNECTION and DB_DATABASE}}.
176
+ DEPLOYED
177
+ error: {
178
+ generate_app_key: "Failed to generate Laravel APP_KEY",
179
+ },
180
+ },
181
+ rails: {
182
+ db_check: {
183
+ validating: "Validating application…",
184
+ checking: "Checking database type…",
185
+ validated: "Database type \"%s\" validated for platform \"Heroku\"",
186
+ problem: "A problem was encountered while checking your database type.",
187
+ sqlite: <<~SQLITE,
188
+ Heroku does not support deployment using the SQLite database system.
189
+ Change the database type using {{command:rails db:system:change --to=[new_db_type]}}. For more info:
190
+ {{underline:https://gorails.com/episodes/rails-6-db-system-change-command}}
191
+ SQLITE
192
+ },
193
+ },
194
+ git: {
195
+ checking: "Checking git repo…",
196
+ initialized: "Git repo initialized",
197
+ what_branch: "What branch would you like to deploy?",
198
+ branch_selected: "{{v}} Git branch {{green:%s}} selected for deploy",
199
+ },
200
+ app: {
201
+ no_apps_found: "No existing Heroku app found. What would you like to do?",
202
+ name: "What is your Heroku app’s name?",
203
+ select: "Specify an existing Heroku app",
204
+ selecting: "Selecting Heroku app %s…",
205
+ selected: "{{v}} Heroku app {{green:%s}} selected",
206
+ create: "Create a new Heroku app",
207
+ creating: "Creating new Heroku app…",
208
+ created: "{{v}} New Heroku app created",
209
+ setting_configs: "Setting Shopify app configs…",
210
+ configs_set: "{{v}} Shopify app configs set",
211
+ },
212
+ },
213
+ },
214
+ connect: {
215
+ help: <<~HELP,
216
+ {{command:%s app connect}}: Connects an existing app to Shopify CLI. Creates a config file.
217
+ Usage: {{command:%s app connect}}
218
+ HELP
219
+ connected: "Project now connected to {{green:%s}}",
220
+ production_warning: <<~MESSAGE,
221
+ {{yellow:! Warning: if you have connected to an {{bold:app in production}}, running {{command:serve}} may update the app URL and cause an outage.
222
+ MESSAGE
223
+ },
224
+ tunnel: {
225
+ help: <<~HELP,
226
+ Start or stop an http tunnel to your local development app using ngrok.
227
+ Usage: {{command:%s app tunnel [ auth | start | stop ]}}
228
+ HELP
229
+ extended_help: <<~HELP,
230
+ {{bold:Subcommands:}}
231
+
232
+ {{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.
233
+ Usage: {{command:%1$s app tunnel auth <token>}}
234
+
235
+ {{cyan:start}}: Starts an ngrok tunnel, will print the URL for an existing tunnel if already running.
236
+ Usage: {{command:%1$s app tunnel start}}
237
+
238
+ {{cyan:stop}}: Stops the ngrok tunnel.
239
+ Usage: {{command:%1$s app tunnel stop}}
240
+
241
+ HELP
242
+ error: {
243
+ token_argument_missing: "{{x}} {{red:auth requires a token argument}}\n\n",
244
+ },
245
+ },
18
246
  serve: {
247
+ help: <<~HELP,
248
+ Start a local development server for your project, as well as a public ngrok tunnel to your localhost.
249
+ Usage: {{command:%s app serve}}
250
+ HELP
251
+ extended_help: <<~HELP,
252
+ {{bold:Options:}}
253
+ {{cyan:--host=HOST}}: Bypass running tunnel and use custom host. HOST must be HTTPS url.
254
+ {{cyan:--port=PORT}}: Use custom port.
255
+ HELP
256
+ open_info: <<~MESSAGE,
257
+ {{*}} To install and start using your app, open this URL in your browser:
258
+ {{green:%s}}
259
+ MESSAGE
260
+ running_server: "Running server…",
19
261
  error: {
20
- invalid_port: "%s is not a valid port.",
21
262
  host_must_be_https: "HOST must be a HTTPS url.",
263
+ invalid_port: "%s is not a valid port.",
22
264
  },
23
265
  },
24
- help: <<~HELP,
25
- Create and manage embedded apps
26
- Usage: {{command:%s app [ rails | node | php ] }}
27
- HELP
266
+ open: {
267
+ help: <<~HELP,
268
+ Open your local development app in the default browser.
269
+ Usage: {{command:%s app open}}
270
+ HELP
271
+ },
28
272
  },
29
273
  error_reporting: {
30
274
  unhandled_error: {
31
275
  message: "{{x}} {{red:An unexpected error occured.}}",
32
- issue_message: "{{red:\tTo \e]8;;#{ShopifyCLI::Constants::Links::NEW_ISSUE}\e\\submit an issue\e]8;;\e\\"\
276
+ issue_message: "{{red:\tTo \e]8;;%s\e\\submit an issue\e]8;;\e\\"\
33
277
  " include the stack trace.}}",
34
278
  stacktrace_message: "{{red:\tTo print the stack trace, add the environment variable %s.}}",
35
279
  },
@@ -213,6 +457,7 @@ module ShopifyCLI
213
457
  not_authenticated: "Failed to authenticate",
214
458
  },
215
459
  login_prompt: "Please ensure you've logged in with {{command:%s login}} and try again",
460
+ token_authentication: "%s environment variable. We'll authenticate using its value as a token.",
216
461
  },
217
462
 
218
463
  options: {
@@ -328,7 +573,7 @@ module ShopifyCLI
328
573
  error: {
329
574
  not_in_project: <<~MESSAGE,
330
575
  {{x}} You are not in a Shopify app project
331
- {{yellow:{{*}}}}{{reset: Run}}{{cyan: shopify rails create}}{{reset: or}}{{cyan: shopify node create}}{{reset: to create your app}}
576
+ {{yellow:{{*}}}}{{reset: Run}}{{cyan: shopify app create}}{{reset: to create your app}}
332
577
  MESSAGE
333
578
  },
334
579
  },
@@ -520,7 +765,7 @@ module ShopifyCLI
520
765
  Anonymized reports will be sent to Shopify.
521
766
  MESSAGE
522
767
  turned_off_message: <<~MESSAGE,
523
- Turn on automatic reporting later wtih {{command:%s reporting on}}.
768
+ Turn on automatic reporting later with {{command:%s reporting on}}.
524
769
  MESSAGE
525
770
  },
526
771
  whoami: {
@@ -9,23 +9,21 @@ module ShopifyCLI
9
9
  migrations_directory: File.expand_path("migrator/migrations", __dir__)
10
10
  )
11
11
  baseline_date = last_migration_date
12
- unless baseline_date.nil?
13
- migrations = migrations(migrations_directory: migrations_directory)
14
- .select { |m|
15
- m.date > baseline_date.to_i
16
- }
17
- .each { |m| m.run }
12
+ unless baseline_date.nil?
13
+ migrations(migrations_directory: migrations_directory)
14
+ .select do |m|
15
+ m.date > baseline_date.to_i
16
+ end
17
+ .each(&:run)
18
18
  end
19
19
 
20
20
  store_last_migration_date
21
21
  end
22
22
 
23
- private
24
-
25
23
  def self.store_last_migration_date
26
24
  ShopifyCLI::DB.set(ShopifyCLI::Constants::StoreKeys::LAST_MIGRATION_DATE => Time.now.to_i)
27
25
  end
28
-
26
+
29
27
  def self.last_migration_date
30
28
  ShopifyCLI::DB.get(ShopifyCLI::Constants::StoreKeys::LAST_MIGRATION_DATE)
31
29
  end
@@ -35,7 +33,7 @@ module ShopifyCLI
35
33
  file_name = File.basename(file_path).gsub(".rb", "")
36
34
  file_name_components = file_name.split("_")
37
35
  date_timestamp = file_name_components[0].to_i
38
- migration_name = file_name_components[1...].join("_")
36
+ migration_name = file_name_components.drop(1).join("_")
39
37
 
40
38
  Migrator::Migration.new(
41
39
  name: migration_name,
@@ -45,4 +43,4 @@ module ShopifyCLI
45
43
  end
46
44
  end
47
45
  end
48
- end
46
+ end
@@ -61,18 +61,11 @@ module ShopifyCLI
61
61
  def api_client(ctx)
62
62
  new(
63
63
  ctx: ctx,
64
- token: access_token(ctx),
64
+ token: IdentityAuth.fetch_or_auth_partners_token(ctx: ctx),
65
65
  url: "https://#{Environment.partners_domain}/api/cli/graphql",
66
66
  )
67
67
  end
68
68
 
69
- def access_token(ctx)
70
- ShopifyCLI::DB.get(:partners_exchange_token) do
71
- IdentityAuth.new(ctx: ctx).authenticate
72
- ShopifyCLI::DB.get(:partners_exchange_token)
73
- end
74
- end
75
-
76
69
  def auth_failure_info(ctx, error)
77
70
  if error.response
78
71
  headers = %w(www-authenticate x-request-id)
@@ -81,7 +81,11 @@ module ShopifyCLI
81
81
  #
82
82
  # #### Example
83
83
  #
84
- # type = ShopifyCLI::Project.current_project_type
84
+ # ShopifyCLI::Project.write(
85
+ # @ctx,
86
+ # project_type: "node",
87
+ # organization_id: form_data.organization_id,
88
+ # )
85
89
  #
86
90
  def write(ctx, project_type:, organization_id:, **identifiers)
87
91
  require "yaml" # takes 20ms, so deferred as late as possible.
@@ -1,5 +1,5 @@
1
1
  module ShopifyCLI
2
- class ProjectCommands < Command
2
+ class ProjectCommand < Command
3
3
  def call(*)
4
4
  @ctx.puts(self.class.help)
5
5
  end
@@ -0,0 +1,25 @@
1
+ module ShopifyCLI
2
+ module Services
3
+ module App
4
+ class ConnectService < BaseService
5
+ attr_reader :app_type, :project, :context
6
+
7
+ def initialize(app_type:, project:, context:)
8
+ @app_type = app_type
9
+ @project = project
10
+ @context = context
11
+ super()
12
+ end
13
+
14
+ def call
15
+ unless project&.env.nil?
16
+ context.puts(context.message("core.app.connect.production_warning"))
17
+ end
18
+
19
+ app = ShopifyCLI::Connect.new(context).default_connect(app_type.to_s)
20
+ context.done(context.message("core.app.connect.connected", app))
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,155 @@
1
+ require "semantic/semantic"
2
+
3
+ module ShopifyCLI
4
+ module Services
5
+ module App
6
+ module Create
7
+ class NodeService < BaseService
8
+ attr_reader :context, :name, :organization_id, :store_domain, :type, :verbose
9
+
10
+ def initialize(name:, organization_id:, store_domain:, type:, verbose:, context:)
11
+ @name = name
12
+ @organization_id = organization_id
13
+ @store_domain = store_domain
14
+ @type = type
15
+ @verbose = verbose
16
+ @context = context
17
+ super()
18
+ end
19
+
20
+ def call
21
+ form = form_data({
22
+ name: name,
23
+ organization_id: organization_id,
24
+ shop_domain: store_domain,
25
+ type: type,
26
+ verbose: verbose,
27
+ })
28
+
29
+ raise ShopifyCLI::AbortSilent if form.nil?
30
+
31
+ check_node
32
+ check_npm
33
+ build(form.name)
34
+
35
+ ShopifyCLI::Project.write(
36
+ context,
37
+ project_type: "node",
38
+ organization_id: form.organization_id,
39
+ )
40
+
41
+ api_client = if ShopifyCLI::Environment.acceptance_test?
42
+ {
43
+ "apiKey" => "public_api_key",
44
+ "apiSecretKeys" => [
45
+ {
46
+ "secret" => "api_secret_key",
47
+ },
48
+ ],
49
+ }
50
+ else
51
+ ShopifyCLI::Tasks::CreateApiClient.call(
52
+ context,
53
+ org_id: form.organization_id,
54
+ title: form.name,
55
+ type: form.type,
56
+ )
57
+ end
58
+
59
+ ShopifyCLI::Resources::EnvFile.new(
60
+ api_key: api_client["apiKey"],
61
+ secret: api_client["apiSecretKeys"].first["secret"],
62
+ shop: form.shop_domain,
63
+ scopes: "write_products,write_customers,write_draft_orders",
64
+ ).write(context)
65
+
66
+ partners_url = ShopifyCLI::PartnersAPI.partners_url_for(form.organization_id, api_client["id"])
67
+
68
+ context.puts(context.message("apps.create.info.created", form.name, partners_url))
69
+ context.puts(context.message("apps.create.info.serve", form.name, ShopifyCLI::TOOL_NAME))
70
+ unless ShopifyCLI::Shopifolk.acting_as_shopify_organization?
71
+ context.puts(context.message("apps.create.info.install", partners_url, form.name))
72
+ end
73
+ end
74
+
75
+ private
76
+
77
+ def form_data(form_options)
78
+ if ShopifyCLI::Environment.acceptance_test?
79
+ Struct.new(:name, :organization_id, :type, :shop_domain, keyword_init: true).new(
80
+ name: form_options[:name],
81
+ organization_id: form_options[:organization_id] || "123",
82
+ shop_domain: form_options[:shop_domain] || "test.shopify.io",
83
+ type: form_options[:type] || "public",
84
+ )
85
+ else
86
+ Node::Forms::Create.ask(context, [], form_options)
87
+ end
88
+ end
89
+
90
+ def check_node
91
+ cmd_path = context.which("node")
92
+ context.abort(context.message("core.app.create.node.error.node_required")) if cmd_path.nil?
93
+
94
+ version, stat = context.capture2e("node", "-v")
95
+ unless stat.success?
96
+ context.abort(context.message("core.app.create.node.error.node_version_failure"))
97
+ end
98
+
99
+ context.done(context.message("core.app.create.node.node_version", version))
100
+ end
101
+
102
+ def check_npm
103
+ cmd_path = context.which("npm")
104
+ context.abort(context.message("core.app.create.node.error.npm_required")) if cmd_path.nil?
105
+
106
+ version, stat = context.capture2e("npm", "-v")
107
+ context.abort(context.message("core.app.create.node.error.npm_version_failure")) unless stat.success?
108
+
109
+ context.done(context.message("core.app.create.node.npm_version", version))
110
+ end
111
+
112
+ def set_npm_config
113
+ # check available npmrc (either user or system) for production registry
114
+ registry, _ = context.capture2("npm config get @shopify:registry")
115
+ return if registry.include?("https://registry.yarnpkg.com")
116
+
117
+ # available npmrc doesn't have production registry =>
118
+ # set a project-based .npmrc
119
+ context.system(
120
+ "npm",
121
+ "--userconfig",
122
+ "./.npmrc",
123
+ "config",
124
+ "set",
125
+ "@shopify:registry",
126
+ "https://registry.yarnpkg.com",
127
+ chdir: context.root
128
+ )
129
+ end
130
+
131
+ def build(name)
132
+ ShopifyCLI::Git.clone("https://github.com/Shopify/shopify-app-node.git", name)
133
+
134
+ context.root = File.join(context.root, name)
135
+
136
+ set_npm_config
137
+ ShopifyCLI::JsDeps.install(context, verbose)
138
+
139
+ begin
140
+ context.rm_r(".git")
141
+ context.rm_r(".github")
142
+ context.rm(File.join("server", "handlers", "client.js"))
143
+ context.rename(
144
+ File.join("server", "handlers", "client.cli.js"),
145
+ File.join("server", "handlers", "client.js")
146
+ )
147
+ rescue Errno::ENOENT => e
148
+ context.debug(e)
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
155
+ end