@shopify/cli-kit 3.39.0 → 3.40.1

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 (767) hide show
  1. package/assets/cli-ruby/.devcontainer.json +5 -0
  2. package/assets/cli-ruby/.rubocop.yml +102 -0
  3. package/assets/cli-ruby/.rubocop_todo.yml +24 -0
  4. package/assets/cli-ruby/.ruby-version +1 -0
  5. package/assets/cli-ruby/CHANGELOG.md +634 -0
  6. package/assets/cli-ruby/CONTRIBUTING.md +3 -0
  7. package/assets/cli-ruby/Codespace.dockerfile +35 -0
  8. package/assets/cli-ruby/Gemfile +31 -0
  9. package/assets/cli-ruby/Gemfile.lock +190 -0
  10. package/{LICENSE → assets/cli-ruby/LICENSE} +2 -0
  11. package/assets/cli-ruby/README.md +30 -0
  12. package/assets/cli-ruby/RELEASING.md +72 -0
  13. package/assets/cli-ruby/Rakefile +243 -0
  14. package/assets/cli-ruby/SECURITY.md +59 -0
  15. package/assets/cli-ruby/Tests.dockerfile +35 -0
  16. package/assets/cli-ruby/assets/logo.png +0 -0
  17. package/assets/cli-ruby/bin/console +11 -0
  18. package/assets/cli-ruby/bin/load_shopify.rb +22 -0
  19. package/assets/cli-ruby/bin/shopify +60 -0
  20. package/assets/cli-ruby/bin/shopify.bat +3 -0
  21. package/assets/cli-ruby/dev.yml +29 -0
  22. package/assets/cli-ruby/docs/README.md +13 -0
  23. package/assets/cli-ruby/docs/contributors/testing.md +27 -0
  24. package/assets/cli-ruby/docs/users/installation.md +3 -0
  25. package/assets/cli-ruby/docs/users/migrate-from-themekit.md +18 -0
  26. package/assets/cli-ruby/ext/javy/hashes/javy-arm-macos-v0.1.0.gz.sha256 +1 -0
  27. package/assets/cli-ruby/ext/javy/hashes/javy-arm-macos-v0.2.0.gz.sha256 +1 -0
  28. package/assets/cli-ruby/ext/javy/hashes/javy-arm-macos-v0.2.1.gz.sha256 +1 -0
  29. package/assets/cli-ruby/ext/javy/hashes/javy-arm-macos-v0.3.0.gz.sha256 +1 -0
  30. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-linux-v0.1.0.gz.sha256 +1 -0
  31. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-linux-v0.2.0.gz.sha256 +1 -0
  32. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-linux-v0.2.1.gz.sha256 +1 -0
  33. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-linux-v0.3.0.gz.sha256 +1 -0
  34. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-macos-v0.1.0.gz.sha256 +1 -0
  35. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-macos-v0.2.0.gz.sha256 +1 -0
  36. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-macos-v0.2.1.gz.sha256 +1 -0
  37. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-macos-v0.3.0.gz.sha256 +1 -0
  38. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-windows-v0.1.0.gz.sha256 +1 -0
  39. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-windows-v0.2.0.gz.sha256 +1 -0
  40. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-windows-v0.2.1.gz.sha256 +1 -0
  41. package/assets/cli-ruby/ext/javy/hashes/javy-x86_64-windows-v0.3.0.gz.sha256 +1 -0
  42. package/assets/cli-ruby/ext/javy/javy.rb +204 -0
  43. package/assets/cli-ruby/ext/javy/version +1 -0
  44. package/assets/cli-ruby/ext/shopify-extensions/extconf.rb +21 -0
  45. package/assets/cli-ruby/ext/shopify-extensions/shopify_extensions.rb +152 -0
  46. package/assets/cli-ruby/ext/shopify-extensions/version +1 -0
  47. package/assets/cli-ruby/features/support/assertions.rb +17 -0
  48. package/assets/cli-ruby/features/support/cli.rb +7 -0
  49. package/assets/cli-ruby/features/support/process.rb +27 -0
  50. package/assets/cli-ruby/features/support/requires.rb +3 -0
  51. package/assets/cli-ruby/lib/docgen/class_template.md.erb +81 -0
  52. package/assets/cli-ruby/lib/docgen/index_template.md.erb +5 -0
  53. package/assets/cli-ruby/lib/docgen/markdown.rb +101 -0
  54. package/assets/cli-ruby/lib/graphql/admin_introspection.graphql +87 -0
  55. package/assets/cli-ruby/lib/graphql/all_organizations.graphql +19 -0
  56. package/assets/cli-ruby/lib/graphql/all_orgs_with_apps.graphql +30 -0
  57. package/assets/cli-ruby/lib/graphql/api_versions.graphql +6 -0
  58. package/assets/cli-ruby/lib/graphql/convert_dev_to_test_store.graphql +10 -0
  59. package/assets/cli-ruby/lib/graphql/create_app.graphql +20 -0
  60. package/assets/cli-ruby/lib/graphql/create_customer.graphql +9 -0
  61. package/assets/cli-ruby/lib/graphql/create_draft_order.graphql +8 -0
  62. package/assets/cli-ruby/lib/graphql/create_product.graphql +9 -0
  63. package/assets/cli-ruby/lib/graphql/extension_create.graphql +36 -0
  64. package/assets/cli-ruby/lib/graphql/extension_update_draft.graphql +18 -0
  65. package/assets/cli-ruby/lib/graphql/fetch_specifications.graphql +14 -0
  66. package/assets/cli-ruby/lib/graphql/find_organization.graphql +18 -0
  67. package/assets/cli-ruby/lib/graphql/find_organization_with_apps.graphql +20 -0
  68. package/assets/cli-ruby/lib/graphql/get_app_by_api_key.graphql +9 -0
  69. package/assets/cli-ruby/lib/graphql/get_app_urls.graphql +6 -0
  70. package/assets/cli-ruby/lib/graphql/get_extension_registrations.graphql +27 -0
  71. package/assets/cli-ruby/lib/graphql/get_variant_id.graphql +16 -0
  72. package/assets/cli-ruby/lib/graphql/update_dashboard_urls.graphql +8 -0
  73. package/assets/cli-ruby/lib/project_types/extension/cli.rb +156 -0
  74. package/assets/cli-ruby/lib/project_types/extension/commands/build.rb +51 -0
  75. package/assets/cli-ruby/lib/project_types/extension/commands/check.rb +51 -0
  76. package/assets/cli-ruby/lib/project_types/extension/commands/connect.rb +35 -0
  77. package/assets/cli-ruby/lib/project_types/extension/commands/create.rb +100 -0
  78. package/assets/cli-ruby/lib/project_types/extension/commands/extension_command.rb +29 -0
  79. package/assets/cli-ruby/lib/project_types/extension/commands/info.rb +86 -0
  80. package/assets/cli-ruby/lib/project_types/extension/commands/push.rb +112 -0
  81. package/assets/cli-ruby/lib/project_types/extension/commands/register.rb +67 -0
  82. package/assets/cli-ruby/lib/project_types/extension/commands/serve.rb +150 -0
  83. package/assets/cli-ruby/lib/project_types/extension/commands/tunnel.rb +73 -0
  84. package/assets/cli-ruby/lib/project_types/extension/errors.rb +9 -0
  85. package/assets/cli-ruby/lib/project_types/extension/extension_project.rb +151 -0
  86. package/assets/cli-ruby/lib/project_types/extension/extension_project_keys.rb +12 -0
  87. package/assets/cli-ruby/lib/project_types/extension/features/argo.rb +50 -0
  88. package/assets/cli-ruby/lib/project_types/extension/features/argo_config.rb +59 -0
  89. package/assets/cli-ruby/lib/project_types/extension/features/argo_dependencies.rb +28 -0
  90. package/assets/cli-ruby/lib/project_types/extension/features/argo_runtime.rb +15 -0
  91. package/assets/cli-ruby/lib/project_types/extension/features/argo_serve.rb +115 -0
  92. package/assets/cli-ruby/lib/project_types/extension/features/argo_setup.rb +54 -0
  93. package/assets/cli-ruby/lib/project_types/extension/features/argo_setup_step.rb +31 -0
  94. package/assets/cli-ruby/lib/project_types/extension/features/argo_setup_steps.rb +51 -0
  95. package/assets/cli-ruby/lib/project_types/extension/features/runtimes/admin.rb +29 -0
  96. package/assets/cli-ruby/lib/project_types/extension/features/runtimes/base.rb +19 -0
  97. package/assets/cli-ruby/lib/project_types/extension/features/runtimes/checkout_post_purchase.rb +23 -0
  98. package/assets/cli-ruby/lib/project_types/extension/features/runtimes/checkout_ui_extension.rb +29 -0
  99. package/assets/cli-ruby/lib/project_types/extension/forms/connect.rb +42 -0
  100. package/assets/cli-ruby/lib/project_types/extension/forms/create.rb +49 -0
  101. package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_app.rb +53 -0
  102. package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_name.rb +48 -0
  103. package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_registration.rb +55 -0
  104. package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_template.rb +37 -0
  105. package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_type.rb +47 -0
  106. package/assets/cli-ruby/lib/project_types/extension/loaders/project.rb +50 -0
  107. package/assets/cli-ruby/lib/project_types/extension/loaders/specification_handler.rb +22 -0
  108. package/assets/cli-ruby/lib/project_types/extension/messages/message_loading.rb +34 -0
  109. package/assets/cli-ruby/lib/project_types/extension/messages/messages.rb +292 -0
  110. package/assets/cli-ruby/lib/project_types/extension/models/app.rb +14 -0
  111. package/assets/cli-ruby/lib/project_types/extension/models/development_server.rb +77 -0
  112. package/assets/cli-ruby/lib/project_types/extension/models/development_server_requirements.rb +56 -0
  113. package/assets/cli-ruby/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
  114. package/assets/cli-ruby/lib/project_types/extension/models/npm_package.rb +44 -0
  115. package/assets/cli-ruby/lib/project_types/extension/models/product.rb +12 -0
  116. package/assets/cli-ruby/lib/project_types/extension/models/registration.rb +20 -0
  117. package/assets/cli-ruby/lib/project_types/extension/models/server_config/app.rb +13 -0
  118. package/assets/cli-ruby/lib/project_types/extension/models/server_config/base.rb +31 -0
  119. package/assets/cli-ruby/lib/project_types/extension/models/server_config/capabilities.rb +11 -0
  120. package/assets/cli-ruby/lib/project_types/extension/models/server_config/development.rb +33 -0
  121. package/assets/cli-ruby/lib/project_types/extension/models/server_config/development_entries.rb +38 -0
  122. package/assets/cli-ruby/lib/project_types/extension/models/server_config/development_renderer.rb +38 -0
  123. package/assets/cli-ruby/lib/project_types/extension/models/server_config/development_resource.rb +13 -0
  124. package/assets/cli-ruby/lib/project_types/extension/models/server_config/extension.rb +46 -0
  125. package/assets/cli-ruby/lib/project_types/extension/models/server_config/root.rb +21 -0
  126. package/assets/cli-ruby/lib/project_types/extension/models/server_config/user.rb +10 -0
  127. package/assets/cli-ruby/lib/project_types/extension/models/specification.rb +41 -0
  128. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +29 -0
  129. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +170 -0
  130. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/default.rb +145 -0
  131. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +122 -0
  132. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/web_pixel_extension.rb +58 -0
  133. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/web_pixel_extension_utils/script_config.rb +33 -0
  134. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/web_pixel_extension_utils/script_config_repository.rb +75 -0
  135. package/assets/cli-ruby/lib/project_types/extension/models/specifications.rb +89 -0
  136. package/assets/cli-ruby/lib/project_types/extension/models/validation_error.rb +17 -0
  137. package/assets/cli-ruby/lib/project_types/extension/models/version.rb +15 -0
  138. package/assets/cli-ruby/lib/project_types/extension/tasks/choose_next_available_port.rb +36 -0
  139. package/assets/cli-ruby/lib/project_types/extension/tasks/configure_features.rb +73 -0
  140. package/assets/cli-ruby/lib/project_types/extension/tasks/configure_options.rb +21 -0
  141. package/assets/cli-ruby/lib/project_types/extension/tasks/convert_server_config.rb +85 -0
  142. package/assets/cli-ruby/lib/project_types/extension/tasks/converters/app_converter.rb +27 -0
  143. package/assets/cli-ruby/lib/project_types/extension/tasks/converters/product_converter.rb +21 -0
  144. package/assets/cli-ruby/lib/project_types/extension/tasks/converters/registration_converter.rb +28 -0
  145. package/assets/cli-ruby/lib/project_types/extension/tasks/converters/validation_error_converter.rb +25 -0
  146. package/assets/cli-ruby/lib/project_types/extension/tasks/converters/version_converter.rb +28 -0
  147. package/assets/cli-ruby/lib/project_types/extension/tasks/create_extension.rb +31 -0
  148. package/assets/cli-ruby/lib/project_types/extension/tasks/ensure_resource_url.rb +39 -0
  149. package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/base.rb +15 -0
  150. package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/build.rb +30 -0
  151. package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/create.rb +30 -0
  152. package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb +57 -0
  153. package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/serve.rb +36 -0
  154. package/assets/cli-ruby/lib/project_types/extension/tasks/fetch_specifications.rb +21 -0
  155. package/assets/cli-ruby/lib/project_types/extension/tasks/find_npm_packages.rb +106 -0
  156. package/assets/cli-ruby/lib/project_types/extension/tasks/find_package_from_json.rb +37 -0
  157. package/assets/cli-ruby/lib/project_types/extension/tasks/get_app.rb +22 -0
  158. package/assets/cli-ruby/lib/project_types/extension/tasks/get_apps.rb +26 -0
  159. package/assets/cli-ruby/lib/project_types/extension/tasks/get_extensions.rb +33 -0
  160. package/assets/cli-ruby/lib/project_types/extension/tasks/get_product.rb +22 -0
  161. package/assets/cli-ruby/lib/project_types/extension/tasks/merge_server_config.rb +47 -0
  162. package/assets/cli-ruby/lib/project_types/extension/tasks/update_draft.rb +29 -0
  163. package/assets/cli-ruby/lib/project_types/extension/tasks/user_errors.rb +45 -0
  164. package/assets/cli-ruby/lib/project_types/node/cli.rb +12 -0
  165. package/assets/cli-ruby/lib/project_types/node/forms/create.rb +45 -0
  166. package/assets/cli-ruby/lib/project_types/node/messages/messages.rb +33 -0
  167. package/assets/cli-ruby/lib/project_types/php/cli.rb +16 -0
  168. package/assets/cli-ruby/lib/project_types/php/forms/create.rb +44 -0
  169. package/assets/cli-ruby/lib/project_types/php/messages/messages.rb +29 -0
  170. package/assets/cli-ruby/lib/project_types/rails/cli.rb +15 -0
  171. package/assets/cli-ruby/lib/project_types/rails/forms/create.rb +75 -0
  172. package/assets/cli-ruby/lib/project_types/rails/gem.rb +110 -0
  173. package/assets/cli-ruby/lib/project_types/rails/messages/messages.rb +101 -0
  174. package/assets/cli-ruby/lib/project_types/script/cli.rb +27 -0
  175. package/assets/cli-ruby/lib/project_types/script/commands/connect.rb +16 -0
  176. package/assets/cli-ruby/lib/project_types/script/commands/create.rb +24 -0
  177. package/assets/cli-ruby/lib/project_types/script/commands/javy.rb +24 -0
  178. package/assets/cli-ruby/lib/project_types/script/commands/push.rb +26 -0
  179. package/assets/cli-ruby/lib/project_types/script/loaders/project.rb +46 -0
  180. package/assets/cli-ruby/lib/project_types/script/loaders/specification_handler.rb +22 -0
  181. package/assets/cli-ruby/lib/project_types/script/messages/messages.rb +11 -0
  182. package/assets/cli-ruby/lib/project_types/theme/cli.rb +33 -0
  183. package/assets/cli-ruby/lib/project_types/theme/commands/check.rb +38 -0
  184. package/assets/cli-ruby/lib/project_types/theme/commands/common/root_helper.rb +93 -0
  185. package/assets/cli-ruby/lib/project_types/theme/commands/common/shop_helper.rb +13 -0
  186. package/assets/cli-ruby/lib/project_types/theme/commands/delete.rb +70 -0
  187. package/assets/cli-ruby/lib/project_types/theme/commands/init.rb +46 -0
  188. package/assets/cli-ruby/lib/project_types/theme/commands/language_server.rb +18 -0
  189. package/assets/cli-ruby/lib/project_types/theme/commands/list.rb +33 -0
  190. package/assets/cli-ruby/lib/project_types/theme/commands/open.rb +73 -0
  191. package/assets/cli-ruby/lib/project_types/theme/commands/package.rb +73 -0
  192. package/assets/cli-ruby/lib/project_types/theme/commands/publish.rb +49 -0
  193. package/assets/cli-ruby/lib/project_types/theme/commands/pull.rb +112 -0
  194. package/assets/cli-ruby/lib/project_types/theme/commands/push.rb +153 -0
  195. package/assets/cli-ruby/lib/project_types/theme/commands/serve.rb +88 -0
  196. package/assets/cli-ruby/lib/project_types/theme/commands/share.rb +62 -0
  197. package/assets/cli-ruby/lib/project_types/theme/conversions/base_glob.rb +65 -0
  198. package/assets/cli-ruby/lib/project_types/theme/conversions/ignore_glob.rb +15 -0
  199. package/assets/cli-ruby/lib/project_types/theme/conversions/include_glob.rb +15 -0
  200. package/assets/cli-ruby/lib/project_types/theme/forms/confirm_store.rb +15 -0
  201. package/assets/cli-ruby/lib/project_types/theme/forms/select.rb +34 -0
  202. package/assets/cli-ruby/lib/project_types/theme/messages/messages.rb +424 -0
  203. package/assets/cli-ruby/lib/project_types/theme/models/specification_handlers/theme.rb +19 -0
  204. package/assets/cli-ruby/lib/project_types/theme/presenters/theme_presenter.rb +48 -0
  205. package/assets/cli-ruby/lib/project_types/theme/presenters/themes_presenter.rb +29 -0
  206. package/assets/cli-ruby/lib/project_types/theme/ui/sync_progress_bar.rb +20 -0
  207. package/assets/cli-ruby/lib/rubygems_plugin.rb +26 -0
  208. package/assets/cli-ruby/lib/shopify_cli/admin_api/populate_resource_command.rb +166 -0
  209. package/assets/cli-ruby/lib/shopify_cli/admin_api/schema.rb +35 -0
  210. package/assets/cli-ruby/lib/shopify_cli/admin_api.rb +163 -0
  211. package/assets/cli-ruby/lib/shopify_cli/api.rb +131 -0
  212. package/assets/cli-ruby/lib/shopify_cli/app_type_detector.rb +36 -0
  213. package/assets/cli-ruby/lib/shopify_cli/assets/post_auth_page/index.html.erb +34 -0
  214. package/assets/cli-ruby/lib/shopify_cli/assets/post_auth_page/style.css +58 -0
  215. package/assets/cli-ruby/lib/shopify_cli/changelog.rb +148 -0
  216. package/assets/cli-ruby/lib/shopify_cli/command/app_sub_command.rb +26 -0
  217. package/assets/cli-ruby/lib/shopify_cli/command/project_command.rb +31 -0
  218. package/assets/cli-ruby/lib/shopify_cli/command/sub_command.rb +21 -0
  219. package/assets/cli-ruby/lib/shopify_cli/command.rb +173 -0
  220. package/assets/cli-ruby/lib/shopify_cli/command_options/command_serve_options.rb +53 -0
  221. package/assets/cli-ruby/lib/shopify_cli/command_options.rb +7 -0
  222. package/assets/cli-ruby/lib/shopify_cli/commands/app/connect.rb +22 -0
  223. package/assets/cli-ruby/lib/shopify_cli/commands/app/create/node.rb +40 -0
  224. package/assets/cli-ruby/lib/shopify_cli/commands/app/create/php.rb +37 -0
  225. package/assets/cli-ruby/lib/shopify_cli/commands/app/create/rails.rb +42 -0
  226. package/assets/cli-ruby/lib/shopify_cli/commands/app/create.rb +28 -0
  227. package/assets/cli-ruby/lib/shopify_cli/commands/app/deploy.rb +51 -0
  228. package/assets/cli-ruby/lib/shopify_cli/commands/app/open.rb +19 -0
  229. package/assets/cli-ruby/lib/shopify_cli/commands/app/serve.rb +51 -0
  230. package/assets/cli-ruby/lib/shopify_cli/commands/app/tunnel.rb +43 -0
  231. package/assets/cli-ruby/lib/shopify_cli/commands/app.rb +29 -0
  232. package/assets/cli-ruby/lib/shopify_cli/commands/config.rb +76 -0
  233. package/assets/cli-ruby/lib/shopify_cli/commands/help.rb +52 -0
  234. package/assets/cli-ruby/lib/shopify_cli/commands/login.rb +98 -0
  235. package/assets/cli-ruby/lib/shopify_cli/commands/logout.rb +50 -0
  236. package/assets/cli-ruby/lib/shopify_cli/commands/populate/customer.rb +25 -0
  237. package/assets/cli-ruby/lib/shopify_cli/commands/populate/draft_order.rb +28 -0
  238. package/assets/cli-ruby/lib/shopify_cli/commands/populate/product.rb +24 -0
  239. package/assets/cli-ruby/lib/shopify_cli/commands/populate.rb +23 -0
  240. package/assets/cli-ruby/lib/shopify_cli/commands/reporting.rb +38 -0
  241. package/assets/cli-ruby/lib/shopify_cli/commands/store.rb +15 -0
  242. package/assets/cli-ruby/lib/shopify_cli/commands/switch.rb +39 -0
  243. package/assets/cli-ruby/lib/shopify_cli/commands/system.rb +165 -0
  244. package/assets/cli-ruby/lib/shopify_cli/commands/version.rb +15 -0
  245. package/assets/cli-ruby/lib/shopify_cli/commands/whoami.rb +28 -0
  246. package/assets/cli-ruby/lib/shopify_cli/commands.rb +36 -0
  247. package/assets/cli-ruby/lib/shopify_cli/connect.rb +32 -0
  248. package/assets/cli-ruby/lib/shopify_cli/constants.rb +91 -0
  249. package/assets/cli-ruby/lib/shopify_cli/context.rb +691 -0
  250. package/assets/cli-ruby/lib/shopify_cli/core/cli_version.rb +20 -0
  251. package/assets/cli-ruby/lib/shopify_cli/core/entry_point.rb +64 -0
  252. package/assets/cli-ruby/lib/shopify_cli/core/executor.rb +23 -0
  253. package/assets/cli-ruby/lib/shopify_cli/core/finalize.rb +13 -0
  254. package/assets/cli-ruby/lib/shopify_cli/core/help_resolver.rb +20 -0
  255. package/assets/cli-ruby/lib/shopify_cli/core/monorail.rb +122 -0
  256. package/assets/cli-ruby/lib/shopify_cli/core.rb +9 -0
  257. package/assets/cli-ruby/lib/shopify_cli/db.rb +114 -0
  258. package/assets/cli-ruby/lib/shopify_cli/environment.rb +198 -0
  259. package/assets/cli-ruby/lib/shopify_cli/exception_reporter.rb +79 -0
  260. package/assets/cli-ruby/lib/shopify_cli/feature.rb +95 -0
  261. package/assets/cli-ruby/lib/shopify_cli/file_system_listener.rb +30 -0
  262. package/assets/cli-ruby/lib/shopify_cli/form.rb +42 -0
  263. package/assets/cli-ruby/lib/shopify_cli/git.rb +320 -0
  264. package/assets/cli-ruby/lib/shopify_cli/github/issue_url_generator.rb +30 -0
  265. package/assets/cli-ruby/lib/shopify_cli/github.rb +5 -0
  266. package/assets/cli-ruby/lib/shopify_cli/helpers/haikunator.rb +92 -0
  267. package/assets/cli-ruby/lib/shopify_cli/helpers.rb +5 -0
  268. package/assets/cli-ruby/lib/shopify_cli/heroku.rb +140 -0
  269. package/assets/cli-ruby/lib/shopify_cli/http_request.rb +43 -0
  270. package/assets/cli-ruby/lib/shopify_cli/identity_auth/env_auth_token.rb +34 -0
  271. package/assets/cli-ruby/lib/shopify_cli/identity_auth/servlet.rb +44 -0
  272. package/assets/cli-ruby/lib/shopify_cli/identity_auth.rb +333 -0
  273. package/assets/cli-ruby/lib/shopify_cli/js_deps.rb +110 -0
  274. package/assets/cli-ruby/lib/shopify_cli/js_system.rb +115 -0
  275. package/assets/cli-ruby/lib/shopify_cli/lazy_delegator.rb +55 -0
  276. package/assets/cli-ruby/lib/shopify_cli/messages/messages.rb +863 -0
  277. package/assets/cli-ruby/lib/shopify_cli/method_object.rb +123 -0
  278. package/assets/cli-ruby/lib/shopify_cli/migrator/migration.rb +27 -0
  279. package/assets/cli-ruby/lib/shopify_cli/migrator/migrations/1631709766_noop.rb +13 -0
  280. package/assets/cli-ruby/lib/shopify_cli/migrator/migrations/1633691650_merge_reporting_configuration.rb +41 -0
  281. package/assets/cli-ruby/lib/shopify_cli/migrator.rb +46 -0
  282. package/assets/cli-ruby/lib/shopify_cli/options.rb +40 -0
  283. package/assets/cli-ruby/lib/shopify_cli/packager.rb +108 -0
  284. package/assets/cli-ruby/lib/shopify_cli/partners_api/app_extensions/job.rb +36 -0
  285. package/assets/cli-ruby/lib/shopify_cli/partners_api/app_extensions.rb +46 -0
  286. package/assets/cli-ruby/lib/shopify_cli/partners_api/organizations.rb +45 -0
  287. package/assets/cli-ruby/lib/shopify_cli/partners_api.rb +91 -0
  288. package/assets/cli-ruby/lib/shopify_cli/php_deps.rb +102 -0
  289. package/assets/cli-ruby/lib/shopify_cli/process_supervision.rb +228 -0
  290. package/assets/cli-ruby/lib/shopify_cli/project.rb +199 -0
  291. package/assets/cli-ruby/lib/shopify_cli/project_commands.rb +16 -0
  292. package/assets/cli-ruby/lib/shopify_cli/project_type.rb +66 -0
  293. package/assets/cli-ruby/lib/shopify_cli/release.rb +197 -0
  294. package/assets/cli-ruby/lib/shopify_cli/reporting_configuration_controller.rb +64 -0
  295. package/assets/cli-ruby/lib/shopify_cli/resolve_constant.rb +25 -0
  296. package/assets/cli-ruby/lib/shopify_cli/resources/env_file.rb +108 -0
  297. package/assets/cli-ruby/lib/shopify_cli/resources.rb +5 -0
  298. package/assets/cli-ruby/lib/shopify_cli/result.rb +448 -0
  299. package/assets/cli-ruby/lib/shopify_cli/sed.rb +19 -0
  300. package/assets/cli-ruby/lib/shopify_cli/services/app/connect_service.rb +25 -0
  301. package/assets/cli-ruby/lib/shopify_cli/services/app/create/node_service.rb +143 -0
  302. package/assets/cli-ruby/lib/shopify_cli/services/app/create/php_service.rb +147 -0
  303. package/assets/cli-ruby/lib/shopify_cli/services/app/create/rails_service.rb +239 -0
  304. package/assets/cli-ruby/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +101 -0
  305. package/assets/cli-ruby/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +135 -0
  306. package/assets/cli-ruby/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +120 -0
  307. package/assets/cli-ruby/lib/shopify_cli/services/app/open_service.rb +19 -0
  308. package/assets/cli-ruby/lib/shopify_cli/services/app/serve/node_service.rb +19 -0
  309. package/assets/cli-ruby/lib/shopify_cli/services/app/serve/php_service.rb +23 -0
  310. package/assets/cli-ruby/lib/shopify_cli/services/app/serve/rails_service.rb +28 -0
  311. package/assets/cli-ruby/lib/shopify_cli/services/app/serve/serve_service.rb +57 -0
  312. package/assets/cli-ruby/lib/shopify_cli/services/app/tunnel/auth_service.rb +21 -0
  313. package/assets/cli-ruby/lib/shopify_cli/services/app/tunnel/start_service.rb +20 -0
  314. package/assets/cli-ruby/lib/shopify_cli/services/app/tunnel/stop_service.rb +20 -0
  315. package/assets/cli-ruby/lib/shopify_cli/services/base_service.rb +13 -0
  316. package/assets/cli-ruby/lib/shopify_cli/services/reporting_service.rb +16 -0
  317. package/assets/cli-ruby/lib/shopify_cli/services.rb +38 -0
  318. package/assets/cli-ruby/lib/shopify_cli/shopifolk.rb +81 -0
  319. package/assets/cli-ruby/lib/shopify_cli/task.rb +20 -0
  320. package/assets/cli-ruby/lib/shopify_cli/tasks/confirm_store.rb +18 -0
  321. package/assets/cli-ruby/lib/shopify_cli/tasks/create_api_client.rb +40 -0
  322. package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_authenticated.rb +19 -0
  323. package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_dev_store.rb +41 -0
  324. package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_env.rb +90 -0
  325. package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_git_dependency.rb +14 -0
  326. package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_loopback_url.rb +20 -0
  327. package/assets/cli-ruby/lib/shopify_cli/tasks/ensure_project_type.rb +14 -0
  328. package/assets/cli-ruby/lib/shopify_cli/tasks/select_org_and_shop.rb +81 -0
  329. package/assets/cli-ruby/lib/shopify_cli/tasks/update_dashboard_urls.rb +57 -0
  330. package/assets/cli-ruby/lib/shopify_cli/tasks.rb +44 -0
  331. package/assets/cli-ruby/lib/shopify_cli/theme/backoff_helper.rb +47 -0
  332. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +73 -0
  333. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/certificate_manager.rb +79 -0
  334. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/errors.rb +9 -0
  335. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/header_hash.rb +98 -0
  336. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hooks/file_change_hook.rb +77 -0
  337. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_deleter.rb +62 -0
  338. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb +63 -0
  339. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/resources/hot-reload-no-script.html +27 -0
  340. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/resources/hot_reload.js +48 -0
  341. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/resources/sse_client.js +43 -0
  342. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/resources/theme.js +114 -0
  343. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/resources/theme_extension.js +121 -0
  344. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/script_injector.rb +57 -0
  345. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/sections_index.rb +50 -0
  346. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload.rb +68 -0
  347. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/local_assets.rb +87 -0
  348. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/proxy.rb +246 -0
  349. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/proxy_param_builder.rb +82 -0
  350. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/reload_mode.rb +34 -0
  351. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/remote_watcher/json_files_update_job.rb +35 -0
  352. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/remote_watcher.rb +44 -0
  353. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/sse.rb +75 -0
  354. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/watcher.rb +61 -0
  355. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/web_server.rb +140 -0
  356. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server.rb +320 -0
  357. package/assets/cli-ruby/lib/shopify_cli/theme/development_theme.rb +101 -0
  358. package/assets/cli-ruby/lib/shopify_cli/theme/extension/app_extension.rb +40 -0
  359. package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/hooks/file_change_hook.rb +68 -0
  360. package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/hot_reload/script_injector.rb +30 -0
  361. package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/hot_reload.rb +13 -0
  362. package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/local_assets.rb +30 -0
  363. package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/proxy_param_builder.rb +94 -0
  364. package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server/watcher.rb +47 -0
  365. package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server.rb +150 -0
  366. package/assets/cli-ruby/lib/shopify_cli/theme/extension/host_theme.rb +104 -0
  367. package/assets/cli-ruby/lib/shopify_cli/theme/extension/syncer/extension_serve_job.rb +133 -0
  368. package/assets/cli-ruby/lib/shopify_cli/theme/extension/syncer/operation.rb +21 -0
  369. package/assets/cli-ruby/lib/shopify_cli/theme/extension/syncer.rb +81 -0
  370. package/assets/cli-ruby/lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb +35 -0
  371. package/assets/cli-ruby/lib/shopify_cli/theme/file.rb +149 -0
  372. package/assets/cli-ruby/lib/shopify_cli/theme/filter/path_matcher.rb +38 -0
  373. package/assets/cli-ruby/lib/shopify_cli/theme/ignore_filter.rb +112 -0
  374. package/assets/cli-ruby/lib/shopify_cli/theme/ignore_helper.rb +37 -0
  375. package/assets/cli-ruby/lib/shopify_cli/theme/include_filter.rb +67 -0
  376. package/assets/cli-ruby/lib/shopify_cli/theme/mime_type.rb +34 -0
  377. package/assets/cli-ruby/lib/shopify_cli/theme/root.rb +62 -0
  378. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/checksums.rb +66 -0
  379. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/downloader.rb +63 -0
  380. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/error_reporter.rb +45 -0
  381. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/merger.rb +53 -0
  382. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/operation.rb +57 -0
  383. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/standard_reporter.rb +32 -0
  384. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/unsupported_script_warning.rb +90 -0
  385. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/bulk.rb +133 -0
  386. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/bulk_item.rb +64 -0
  387. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/bulk_job.rb +139 -0
  388. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/bulk_request.rb +30 -0
  389. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/forms/apply_to_all.rb +41 -0
  390. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/forms/apply_to_all_form.rb +37 -0
  391. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/forms/base_strategy_form.rb +64 -0
  392. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/forms/select_delete_strategy.rb +29 -0
  393. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/forms/select_update_strategy.rb +30 -0
  394. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/json_delete_handler.rb +49 -0
  395. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader/json_update_handler.rb +71 -0
  396. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/uploader.rb +231 -0
  397. package/assets/cli-ruby/lib/shopify_cli/theme/syncer.rb +386 -0
  398. package/assets/cli-ruby/lib/shopify_cli/theme/theme.rb +212 -0
  399. package/assets/cli-ruby/lib/shopify_cli/theme/theme_access_api.rb +89 -0
  400. package/assets/cli-ruby/lib/shopify_cli/theme/theme_admin_api.rb +101 -0
  401. package/assets/cli-ruby/lib/shopify_cli/thread_pool/job.rb +35 -0
  402. package/assets/cli-ruby/lib/shopify_cli/thread_pool.rb +49 -0
  403. package/assets/cli-ruby/lib/shopify_cli/transform_data_structure.rb +87 -0
  404. package/assets/cli-ruby/lib/shopify_cli/tunnel.rb +255 -0
  405. package/assets/cli-ruby/lib/shopify_cli/utilities.rb +21 -0
  406. package/assets/cli-ruby/lib/shopify_cli/version.rb +3 -0
  407. package/assets/cli-ruby/lib/shopify_cli.rb +191 -0
  408. package/assets/cli-ruby/shipit.rubygems.yml +3 -0
  409. package/assets/cli-ruby/shopify-cli.gemspec +54 -0
  410. package/assets/cli-ruby/shopify-dev +16 -0
  411. package/assets/cli-ruby/test/minitest_ext.rb +115 -0
  412. package/assets/cli-ruby/test/project_types/extension/extension_test_helpers.rb +70 -0
  413. package/assets/cli-ruby/test/shopify-cli/migrator/migrations/migration_helper.rb +20 -0
  414. package/assets/cli-ruby/test/test_helpers.rb +18 -0
  415. package/assets/cli-ruby/utilities/constants.rb +7 -0
  416. package/assets/cli-ruby/utilities/docker/container.rb +104 -0
  417. package/assets/cli-ruby/utilities/docker.rb +89 -0
  418. package/assets/cli-ruby/utilities/utilities.rb +6 -0
  419. package/assets/cli-ruby/vendor/deps/cli-kit/REVISION +1 -0
  420. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/autocall.rb +21 -0
  421. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +49 -0
  422. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +94 -0
  423. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/config.rb +133 -0
  424. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +123 -0
  425. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/executor.rb +79 -0
  426. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/ini.rb +102 -0
  427. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +82 -0
  428. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/logger.rb +82 -0
  429. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +60 -0
  430. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/ruby_backports/enumerable.rb +6 -0
  431. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +244 -0
  432. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/support.rb +9 -0
  433. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/system.rb +243 -0
  434. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/util.rb +193 -0
  435. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit/version.rb +5 -0
  436. package/assets/cli-ruby/vendor/deps/cli-kit/lib/cli/kit.rb +60 -0
  437. package/assets/cli-ruby/vendor/deps/cli-ui/REVISION +1 -0
  438. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +157 -0
  439. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/color.rb +84 -0
  440. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +192 -0
  441. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +98 -0
  442. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +166 -0
  443. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +139 -0
  444. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +120 -0
  445. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/frame.rb +269 -0
  446. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +84 -0
  447. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/os.rb +73 -0
  448. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/printer.rb +59 -0
  449. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/progress.rb +90 -0
  450. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +484 -0
  451. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +29 -0
  452. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +282 -0
  453. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +40 -0
  454. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +263 -0
  455. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +66 -0
  456. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +232 -0
  457. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +46 -0
  458. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +102 -0
  459. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/version.rb +5 -0
  460. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +27 -0
  461. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +61 -0
  462. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +77 -0
  463. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +56 -0
  464. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui.rb +233 -0
  465. package/assets/cli-ruby/vendor/deps/ruby2_keywords/LICENSE +22 -0
  466. package/assets/cli-ruby/vendor/deps/ruby2_keywords/README.md +67 -0
  467. package/assets/cli-ruby/vendor/deps/ruby2_keywords/Rakefile +54 -0
  468. package/assets/cli-ruby/vendor/deps/ruby2_keywords/lib/ruby2_keywords.rb +57 -0
  469. package/assets/cli-ruby/vendor/deps/ruby2_keywords/ruby2_keywords.gemspec +18 -0
  470. package/assets/cli-ruby/vendor/deps/ruby2_keywords/test/test_keyword.rb +41 -0
  471. package/assets/cli-ruby/vendor/deps/smart_properties/REVISION +1 -0
  472. package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/errors.rb +114 -0
  473. package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/property.rb +168 -0
  474. package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/property_collection.rb +83 -0
  475. package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/validations/ancestor.rb +27 -0
  476. package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/validations.rb +8 -0
  477. package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties/version.rb +3 -0
  478. package/assets/cli-ruby/vendor/deps/smart_properties/lib/smart_properties.rb +174 -0
  479. package/assets/cli-ruby/vendor/deps/webrick/Gemfile +3 -0
  480. package/assets/cli-ruby/vendor/deps/webrick/LICENSE.txt +22 -0
  481. package/assets/cli-ruby/vendor/deps/webrick/README.md +61 -0
  482. package/assets/cli-ruby/vendor/deps/webrick/Rakefile +10 -0
  483. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/accesslog.rb +157 -0
  484. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/cgi.rb +313 -0
  485. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/compat.rb +36 -0
  486. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/config.rb +158 -0
  487. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/cookie.rb +172 -0
  488. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/htmlutils.rb +30 -0
  489. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +117 -0
  490. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +116 -0
  491. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +395 -0
  492. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +132 -0
  493. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +97 -0
  494. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +158 -0
  495. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +53 -0
  496. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpauth.rb +96 -0
  497. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpproxy.rb +354 -0
  498. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httprequest.rb +636 -0
  499. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpresponse.rb +564 -0
  500. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/https.rb +152 -0
  501. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpserver.rb +294 -0
  502. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +152 -0
  503. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +47 -0
  504. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +126 -0
  505. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +88 -0
  506. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +552 -0
  507. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +47 -0
  508. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpservlet.rb +23 -0
  509. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpstatus.rb +194 -0
  510. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httputils.rb +512 -0
  511. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/httpversion.rb +76 -0
  512. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/log.rb +156 -0
  513. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/server.rb +381 -0
  514. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/ssl.rb +215 -0
  515. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/utils.rb +265 -0
  516. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick/version.rb +18 -0
  517. package/assets/cli-ruby/vendor/deps/webrick/lib/webrick.rb +232 -0
  518. package/assets/cli-ruby/vendor/deps/webrick/webrick.gemspec +74 -0
  519. package/assets/cli-ruby/vendor/gen/lib/gen/commands/help.rb +20 -0
  520. package/assets/cli-ruby/vendor/gen/lib/gen/commands/new.rb +21 -0
  521. package/assets/cli-ruby/vendor/gen/lib/gen/commands.rb +18 -0
  522. package/assets/cli-ruby/vendor/gen/lib/gen/entry_point.rb +10 -0
  523. package/assets/cli-ruby/vendor/gen/lib/gen/generator.rb +165 -0
  524. package/assets/cli-ruby/vendor/gen/lib/gen.rb +39 -0
  525. package/assets/cli-ruby/vendor/gen/template/Gemfile +10 -0
  526. package/assets/cli-ruby/vendor/gen/template/README.md +1 -0
  527. package/assets/cli-ruby/vendor/gen/template/bin/testunit +23 -0
  528. package/assets/cli-ruby/vendor/gen/template/bin/update-deps +97 -0
  529. package/assets/cli-ruby/vendor/gen/template/dev-gems.yml +3 -0
  530. package/assets/cli-ruby/vendor/gen/template/dev-vendor.yml +4 -0
  531. package/assets/cli-ruby/vendor/gen/template/exe/__app__-gems +17 -0
  532. package/assets/cli-ruby/vendor/gen/template/exe/__app__-vendor +18 -0
  533. package/assets/cli-ruby/vendor/gen/template/lib/__app__/commands/example.rb +19 -0
  534. package/assets/cli-ruby/vendor/gen/template/lib/__app__/commands/help.rb +21 -0
  535. package/assets/cli-ruby/vendor/gen/template/lib/__app__/commands.rb +18 -0
  536. package/assets/cli-ruby/vendor/gen/template/lib/__app__/entry_point.rb +10 -0
  537. package/assets/cli-ruby/vendor/gen/template/lib/__app__.rb +33 -0
  538. package/assets/cli-ruby/vendor/gen/template/test/example_test.rb +17 -0
  539. package/assets/cli-ruby/vendor/gen/template/test/test_helper.rb +22 -0
  540. package/assets/cli-ruby/vendor/lib/semantic/LICENSE +20 -0
  541. package/assets/cli-ruby/vendor/lib/semantic/semantic.rb +4 -0
  542. package/assets/cli-ruby/vendor/lib/semantic/version.rb +179 -0
  543. package/dist/private/node/analytics.js +1 -1
  544. package/dist/private/node/analytics.js.map +1 -1
  545. package/dist/private/node/api/headers.js +2 -2
  546. package/dist/private/node/api/headers.js.map +1 -1
  547. package/dist/private/node/constants.d.ts +1 -1
  548. package/dist/private/node/constants.js +1 -1
  549. package/dist/private/node/constants.js.map +1 -1
  550. package/dist/private/node/{environment → context}/service.d.ts +0 -0
  551. package/dist/private/node/{environment → context}/service.js +1 -1
  552. package/dist/private/node/context/service.js.map +1 -0
  553. package/dist/private/node/{environment → context}/spin-cache.d.ts +0 -0
  554. package/dist/private/node/{environment → context}/spin-cache.js +0 -0
  555. package/dist/private/node/context/spin-cache.js.map +1 -0
  556. package/dist/private/node/{environment → context}/utilities.d.ts +0 -0
  557. package/dist/private/node/{environment → context}/utilities.js +0 -0
  558. package/dist/private/node/context/utilities.js.map +1 -0
  559. package/dist/private/node/session/authorize.js +13 -3
  560. package/dist/private/node/session/authorize.js.map +1 -1
  561. package/dist/private/node/session/device-authorization.js +1 -1
  562. package/dist/private/node/session/device-authorization.js.map +1 -1
  563. package/dist/private/node/session/exchange.js +1 -1
  564. package/dist/private/node/session/exchange.js.map +1 -1
  565. package/dist/private/node/session/identity-token-validation.js +1 -1
  566. package/dist/private/node/session/identity-token-validation.js.map +1 -1
  567. package/dist/private/node/session/identity.js +1 -1
  568. package/dist/private/node/session/identity.js.map +1 -1
  569. package/dist/private/node/session/validate.js +1 -1
  570. package/dist/private/node/session/validate.js.map +1 -1
  571. package/dist/private/node/session.js +3 -3
  572. package/dist/private/node/session.js.map +1 -1
  573. package/dist/private/node/testing/ui.d.ts +31 -0
  574. package/dist/private/node/testing/ui.js +32 -1
  575. package/dist/private/node/testing/ui.js.map +1 -1
  576. package/dist/private/node/ui/components/Alert.d.ts +7 -7
  577. package/dist/private/node/ui/components/Alert.js +14 -13
  578. package/dist/private/node/ui/components/Alert.js.map +1 -1
  579. package/dist/private/node/ui/components/Alert.test.js +18 -4
  580. package/dist/private/node/ui/components/Alert.test.js.map +1 -1
  581. package/dist/private/node/ui/components/AutocompletePrompt.d.ts +5 -5
  582. package/dist/private/node/ui/components/AutocompletePrompt.js +10 -8
  583. package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
  584. package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
  585. package/dist/private/node/ui/components/Banner.d.ts +3 -3
  586. package/dist/private/node/ui/components/Banner.js.map +1 -1
  587. package/dist/private/node/ui/components/Command.d.ts +3 -3
  588. package/dist/private/node/ui/components/Command.js.map +1 -1
  589. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +9 -3
  590. package/dist/private/node/ui/components/ConcurrentOutput.js +31 -16
  591. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  592. package/dist/private/node/ui/components/ConcurrentOutput.test.js +36 -12
  593. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  594. package/dist/private/node/ui/components/FatalError.d.ts +2 -2
  595. package/dist/private/node/ui/components/FatalError.js +10 -10
  596. package/dist/private/node/ui/components/FatalError.js.map +1 -1
  597. package/dist/private/node/ui/components/FilePath.d.ts +3 -3
  598. package/dist/private/node/ui/components/FilePath.js +1 -4
  599. package/dist/private/node/ui/components/FilePath.js.map +1 -1
  600. package/dist/private/node/ui/components/FilePath.test.js +1 -1
  601. package/dist/private/node/ui/components/FilePath.test.js.map +1 -1
  602. package/dist/private/node/ui/components/FullScreen.d.ts +3 -3
  603. package/dist/private/node/ui/components/FullScreen.js +1 -1
  604. package/dist/private/node/ui/components/FullScreen.js.map +1 -1
  605. package/dist/private/node/ui/components/Link.d.ts +3 -3
  606. package/dist/private/node/ui/components/Link.js.map +1 -1
  607. package/dist/private/node/ui/components/List.d.ts +6 -5
  608. package/dist/private/node/ui/components/List.js +4 -3
  609. package/dist/private/node/ui/components/List.js.map +1 -1
  610. package/dist/private/node/ui/components/Prompts/InfoTable.d.ts +6 -5
  611. package/dist/private/node/ui/components/Prompts/InfoTable.js +5 -5
  612. package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
  613. package/dist/private/node/ui/components/Prompts/InfoTable.test.d.ts +1 -0
  614. package/dist/private/node/ui/components/Prompts/InfoTable.test.js +29 -0
  615. package/dist/private/node/ui/components/Prompts/InfoTable.test.js.map +1 -0
  616. package/dist/private/node/ui/components/SelectInput.d.ts +9 -3
  617. package/dist/private/node/ui/components/SelectInput.js +24 -17
  618. package/dist/private/node/ui/components/SelectInput.js.map +1 -1
  619. package/dist/private/node/ui/components/SelectInput.test.js +36 -8
  620. package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
  621. package/dist/private/node/ui/components/SelectPrompt.d.ts +8 -7
  622. package/dist/private/node/ui/components/SelectPrompt.js +22 -13
  623. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
  624. package/dist/private/node/ui/components/SelectPrompt.test.js +27 -2
  625. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  626. package/dist/private/node/ui/components/Subdued.d.ts +3 -3
  627. package/dist/private/node/ui/components/Subdued.js.map +1 -1
  628. package/dist/private/node/ui/components/Table/Row.d.ts +2 -2
  629. package/dist/private/node/ui/components/Table/Row.js +3 -2
  630. package/dist/private/node/ui/components/Table/Row.js.map +1 -1
  631. package/dist/private/node/ui/components/Table/Table.d.ts +10 -7
  632. package/dist/private/node/ui/components/Table/Table.js +3 -1
  633. package/dist/private/node/ui/components/Table/Table.js.map +1 -1
  634. package/dist/private/node/ui/components/Table/Table.test.js +1 -1
  635. package/dist/private/node/ui/components/Table/Table.test.js.map +1 -1
  636. package/dist/private/node/ui/components/Tasks.d.ts +2 -2
  637. package/dist/private/node/ui/components/Tasks.js +2 -1
  638. package/dist/private/node/ui/components/Tasks.js.map +1 -1
  639. package/dist/private/node/ui/components/Tasks.test.js +1 -1
  640. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  641. package/dist/private/node/ui/components/TextAnimation.d.ts +3 -3
  642. package/dist/private/node/ui/components/TextAnimation.js.map +1 -1
  643. package/dist/private/node/ui/components/TextInput.d.ts +3 -3
  644. package/dist/private/node/ui/components/TextInput.js +1 -2
  645. package/dist/private/node/ui/components/TextInput.js.map +1 -1
  646. package/dist/private/node/ui/components/TextInput.test.js +1 -1
  647. package/dist/private/node/ui/components/TextInput.test.js.map +1 -1
  648. package/dist/private/node/ui/components/TextPrompt.d.ts +3 -3
  649. package/dist/private/node/ui/components/TextPrompt.js +5 -4
  650. package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
  651. package/dist/private/node/ui/components/TextPrompt.test.js +2 -2
  652. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
  653. package/dist/private/node/ui/components/TextWithBackground.d.ts +12 -0
  654. package/dist/private/node/ui/components/TextWithBackground.js +39 -0
  655. package/dist/private/node/ui/components/TextWithBackground.js.map +1 -0
  656. package/dist/private/node/ui/components/TokenizedText.d.ts +17 -13
  657. package/dist/private/node/ui/components/TokenizedText.js +24 -6
  658. package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
  659. package/dist/private/node/ui/components/TokenizedText.test.js +7 -2
  660. package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
  661. package/dist/private/node/ui/components/UserInput.d.ts +3 -3
  662. package/dist/private/node/ui/components/UserInput.js.map +1 -1
  663. package/dist/private/node/ui/hooks/use-async-and-unmount.d.ts +1 -1
  664. package/dist/private/node/ui/hooks/use-async-and-unmount.js +1 -1
  665. package/dist/private/node/ui/hooks/use-async-and-unmount.js.map +1 -1
  666. package/dist/private/node/ui/hooks/use-layout.d.ts +1 -0
  667. package/dist/private/node/ui/hooks/use-layout.js +1 -0
  668. package/dist/private/node/ui/hooks/use-layout.js.map +1 -1
  669. package/dist/private/node/ui/utilities.d.ts +1 -1
  670. package/dist/private/node/ui.js +3 -2
  671. package/dist/private/node/ui.js.map +1 -1
  672. package/dist/public/common/string.d.ts +2 -2
  673. package/dist/public/common/string.js.map +1 -1
  674. package/dist/public/common/version.d.ts +1 -1
  675. package/dist/public/common/version.js +1 -1
  676. package/dist/public/common/version.js.map +1 -1
  677. package/dist/public/node/analytics.js +1 -1
  678. package/dist/public/node/analytics.js.map +1 -1
  679. package/dist/public/node/api/partners.js +1 -1
  680. package/dist/public/node/api/partners.js.map +1 -1
  681. package/dist/public/node/base-command.d.ts +3 -3
  682. package/dist/public/node/base-command.js +33 -31
  683. package/dist/public/node/base-command.js.map +1 -1
  684. package/dist/public/node/cli.d.ts +1 -1
  685. package/dist/public/node/cli.js +6 -5
  686. package/dist/public/node/cli.js.map +1 -1
  687. package/dist/public/node/{environment → context}/fqdn.d.ts +0 -0
  688. package/dist/public/node/{environment → context}/fqdn.js +1 -1
  689. package/dist/public/node/context/fqdn.js.map +1 -0
  690. package/dist/public/node/{environment → context}/local.d.ts +3 -3
  691. package/dist/public/node/{environment → context}/local.js +6 -6
  692. package/dist/public/node/context/local.js.map +1 -0
  693. package/dist/public/node/{environment → context}/spin.d.ts +0 -0
  694. package/dist/public/node/{environment → context}/spin.js +3 -3
  695. package/dist/public/node/context/spin.js.map +1 -0
  696. package/dist/public/node/environments.d.ts +15 -0
  697. package/dist/public/node/environments.js +33 -0
  698. package/dist/public/node/environments.js.map +1 -0
  699. package/dist/public/node/error.d.ts +5 -5
  700. package/dist/public/node/error.js.map +1 -1
  701. package/dist/public/node/git.js +1 -1
  702. package/dist/public/node/git.js.map +1 -1
  703. package/dist/public/node/hooks/postrun.d.ts +1 -1
  704. package/dist/public/node/hooks/postrun.js +1 -1
  705. package/dist/public/node/hooks/postrun.js.map +1 -1
  706. package/dist/public/node/http.d.ts +1 -0
  707. package/dist/public/node/http.js +1 -0
  708. package/dist/public/node/http.js.map +1 -1
  709. package/dist/public/node/metadata.js +1 -1
  710. package/dist/public/node/metadata.js.map +1 -1
  711. package/dist/public/node/output.js +1 -1
  712. package/dist/public/node/output.js.map +1 -1
  713. package/dist/public/node/ruby.d.ts +1 -0
  714. package/dist/public/node/ruby.js +43 -20
  715. package/dist/public/node/ruby.js.map +1 -1
  716. package/dist/public/node/session.js +1 -1
  717. package/dist/public/node/session.js.map +1 -1
  718. package/dist/public/node/themes/generate-theme-name.d.ts +1 -0
  719. package/dist/public/node/themes/generate-theme-name.js +13 -0
  720. package/dist/public/node/themes/generate-theme-name.js.map +1 -0
  721. package/dist/public/node/themes/models/theme.d.ts +11 -0
  722. package/dist/public/node/themes/models/theme.js +29 -0
  723. package/dist/public/node/themes/models/theme.js.map +1 -0
  724. package/dist/public/node/themes/replace-invalid-characters.d.ts +1 -0
  725. package/dist/public/node/themes/replace-invalid-characters.js +6 -0
  726. package/dist/public/node/themes/replace-invalid-characters.js.map +1 -0
  727. package/dist/public/node/themes/theme-manager.d.ts +13 -0
  728. package/dist/public/node/themes/theme-manager.js +40 -0
  729. package/dist/public/node/themes/theme-manager.js.map +1 -0
  730. package/dist/public/node/themes/theme-urls.d.ts +5 -0
  731. package/dist/public/node/themes/theme-urls.js +16 -0
  732. package/dist/public/node/themes/theme-urls.js.map +1 -0
  733. package/dist/public/node/themes/themes-api/headers.d.ts +3 -0
  734. package/dist/public/node/themes/themes-api/headers.js +29 -0
  735. package/dist/public/node/themes/themes-api/headers.js.map +1 -0
  736. package/dist/public/node/themes/themes-api/retry.d.ts +1 -0
  737. package/dist/public/node/themes/themes-api/retry.js +6 -0
  738. package/dist/public/node/themes/themes-api/retry.js.map +1 -0
  739. package/dist/public/node/themes/themes-api/throttler.d.ts +2 -0
  740. package/dist/public/node/themes/themes-api/throttler.js +82 -0
  741. package/dist/public/node/themes/themes-api/throttler.js.map +1 -0
  742. package/dist/public/node/themes/themes-api.d.ts +9 -0
  743. package/dist/public/node/themes/themes-api.js +85 -0
  744. package/dist/public/node/themes/themes-api.js.map +1 -0
  745. package/dist/public/node/ui.d.ts +25 -26
  746. package/dist/public/node/ui.js +47 -5
  747. package/dist/public/node/ui.js.map +1 -1
  748. package/dist/tsconfig.tsbuildinfo +1 -1
  749. package/package.json +11 -5
  750. package/dist/index.d.ts +0 -1
  751. package/dist/index.js +0 -2
  752. package/dist/index.js.map +0 -1
  753. package/dist/private/node/environment/service.js.map +0 -1
  754. package/dist/private/node/environment/spin-cache.js.map +0 -1
  755. package/dist/private/node/environment/utilities.js.map +0 -1
  756. package/dist/public/node/environment/fqdn.js.map +0 -1
  757. package/dist/public/node/environment/local.js.map +0 -1
  758. package/dist/public/node/environment/spin.js.map +0 -1
  759. package/dist/public/node/presets.d.ts +0 -8
  760. package/dist/public/node/presets.js +0 -26
  761. package/dist/public/node/presets.js.map +0 -1
  762. package/dist/ui/executor.d.ts +0 -2
  763. package/dist/ui/executor.js +0 -56
  764. package/dist/ui/executor.js.map +0 -1
  765. package/dist/ui.d.ts +0 -40
  766. package/dist/ui.js +0 -91
  767. package/dist/ui.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { OutputMessage } from '../../public/node/output.js';
2
- import { TokenItem } from '../../private/node/ui/components/TokenizedText.js';
2
+ import { InlineToken, TokenItem } from '../../private/node/ui/components/TokenizedText.js';
3
3
  export { ExtendableError } from 'ts-error';
4
4
  declare enum FatalErrorType {
5
5
  Abort = 0,
@@ -15,7 +15,7 @@ export declare class CancelExecution extends Error {
15
15
  export declare abstract class FatalError extends Error {
16
16
  tryMessage: TokenItem | null;
17
17
  type: FatalErrorType;
18
- nextSteps?: TokenItem[];
18
+ nextSteps?: TokenItem<InlineToken>[];
19
19
  /**
20
20
  * Creates a new FatalError error.
21
21
  *
@@ -26,15 +26,15 @@ export declare abstract class FatalError extends Error {
26
26
  * if you need to style the message inside the error Banner component.
27
27
  * @param nextSteps - Message to show as "next steps" with suggestions to solve the issue.
28
28
  */
29
- constructor(message: OutputMessage, type: FatalErrorType, tryMessage?: TokenItem | OutputMessage | null, nextSteps?: TokenItem[]);
29
+ constructor(message: OutputMessage, type: FatalErrorType, tryMessage?: TokenItem | OutputMessage | null, nextSteps?: TokenItem<InlineToken>[]);
30
30
  }
31
31
  /**
32
32
  * An abort error is a fatal error that shouldn't be reported as a bug.
33
33
  * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer.
34
34
  */
35
35
  export declare class AbortError extends FatalError {
36
- nextSteps?: TokenItem[];
37
- constructor(message: OutputMessage, tryMessage?: TokenItem | OutputMessage | null, nextSteps?: TokenItem[]);
36
+ nextSteps?: TokenItem<InlineToken>[];
37
+ constructor(message: OutputMessage, tryMessage?: TokenItem | OutputMessage | null, nextSteps?: TokenItem<InlineToken>[]);
38
38
  }
39
39
  /**
40
40
  * An external error is similar to Abort but has extra command and args attributes.
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/public/node/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAA;AACxC,OAAO,EAAgB,gBAAgB,EAAE,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAC5F,OAAO,EAAC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,WAAW,CAAC,KAAc;IACxC,IAAI,KAAK,YAAY,MAAM,CAAC,QAAQ,EAAE;QACpC,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACjD,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;KACpC;SAAM;QACL,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;KAC9B;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,OAAO,CAAC,KAAc;IAC7B,IAAI;QACF,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC1D,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,IAAI,CAAA;KACZ;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG,EAAE;QACrC,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAgB;IACxD,OAAO,aAAa,CAAC,QAAQ,CAAC;SAC3B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;AAC9B,CAAC","sourcesContent":["import {renderFatalError} from './ui.js'\nimport {OutputMessage, stringifyMessage, TokenizedString} from '../../public/node/output.js'\nimport {normalizePath} from '../../public/node/path.js'\nimport {TokenItem} from '../../private/node/ui/components/TokenizedText.js'\nimport {Errors} from '@oclif/core'\n\nexport {ExtendableError} from 'ts-error'\n\nenum FatalErrorType {\n Abort,\n AbortSilent,\n Bug,\n}\n\nexport class CancelExecution extends Error {}\n\n/**\n * A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.\n * There shouldn't be code that catches fatal errors.\n */\nexport abstract class FatalError extends Error {\n tryMessage: TokenItem | null\n type: FatalErrorType\n nextSteps?: TokenItem[]\n /**\n * Creates a new FatalError error.\n *\n * @param message - The error message.\n * @param type - The type of fatal error.\n * @param tryMessage - The message that recommends next steps to the user.\n * You can pass a string a {@link TokenizedString} or a {@link TokenItem}\n * if you need to style the message inside the error Banner component.\n * @param nextSteps - Message to show as \"next steps\" with suggestions to solve the issue.\n */\n constructor(\n message: OutputMessage,\n type: FatalErrorType,\n tryMessage: TokenItem | OutputMessage | null = null,\n nextSteps?: TokenItem[],\n ) {\n super(stringifyMessage(message))\n\n if (tryMessage) {\n if (tryMessage instanceof TokenizedString) {\n this.tryMessage = stringifyMessage(tryMessage)\n } else {\n this.tryMessage = tryMessage\n }\n } else {\n this.tryMessage = null\n }\n\n this.type = type\n this.nextSteps = nextSteps\n }\n}\n\n/**\n * An abort error is a fatal error that shouldn't be reported as a bug.\n * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer.\n */\nexport class AbortError extends FatalError {\n nextSteps?: TokenItem[]\n constructor(message: OutputMessage, tryMessage: TokenItem | OutputMessage | null = null, nextSteps?: TokenItem[]) {\n super(message, FatalErrorType.Abort, tryMessage, nextSteps)\n }\n}\n\n/**\n * An external error is similar to Abort but has extra command and args attributes.\n * This is useful to represent errors coming from external commands, usually executed by execa.\n */\nexport class ExternalError extends FatalError {\n command: string\n args: string[]\n\n constructor(\n message: OutputMessage,\n command: string,\n args: string[],\n tryMessage: TokenItem | OutputMessage | null = null,\n ) {\n super(message, FatalErrorType.Abort, tryMessage)\n this.command = command\n this.args = args\n }\n}\n\nexport class AbortSilentError extends FatalError {\n constructor() {\n super('', FatalErrorType.AbortSilent)\n }\n}\n\n/**\n * A bug error is an error that represents a bug and therefore should be reported.\n */\nexport class BugError extends FatalError {\n constructor(message: OutputMessage, tryMessage: TokenItem | null = null) {\n super(message, FatalErrorType.Bug, tryMessage)\n }\n}\n\n/**\n * A function that handles errors that blow up in the CLI.\n *\n * @param error - Error to be handled.\n * @returns A promise that resolves with the error passed.\n */\nexport async function handler(error: unknown): Promise<unknown> {\n let fatal: FatalError\n if (isFatal(error)) {\n fatal = error\n } else if (typeof error === 'string') {\n fatal = new BugError(error)\n } else if (error instanceof Error) {\n fatal = new BugError(error.message)\n fatal.stack = error.stack\n } else {\n // errors can come in all shapes and sizes...\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const maybeError = error as any\n fatal = new BugError(maybeError?.message ?? 'Unknown error')\n if (maybeError?.stack) {\n fatal.stack = maybeError?.stack\n }\n }\n\n renderFatalError(fatal)\n return Promise.resolve(error)\n}\n\n/**\n * A function that maps an error to an Abort with the stack trace when coming from the CLI.\n *\n * @param error - Error to be mapped.\n * @returns A promise that resolves with the new error object.\n */\nexport function errorMapper(error: unknown): Promise<unknown> {\n if (error instanceof Errors.CLIError) {\n const mappedError = new AbortError(error.message)\n mappedError.stack = error.stack\n return Promise.resolve(mappedError)\n } else {\n return Promise.resolve(error)\n }\n}\n\n/**\n * A function that checks if an error is a fatal one.\n *\n * @param error - Error to be checked.\n * @returns A boolean indicating if the error is a fatal one.\n */\nfunction isFatal(error: unknown): error is FatalError {\n try {\n return Object.prototype.hasOwnProperty.call(error, 'type')\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * A function that checks if an error should be reported.\n *\n * @param error - Error to be checked.\n * @returns A boolean indicating if the error should be reported.\n */\nexport function shouldReportError(error: unknown): boolean {\n if (!isFatal(error)) {\n return true\n }\n if (error.type === FatalErrorType.Bug) {\n return true\n }\n return false\n}\n\n/**\n * Stack traces usually have file:// - we strip that and also remove the Windows drive designation.\n *\n * @param filePath - Path to be cleaned.\n * @returns The cleaned path.\n */\nexport function cleanSingleStackTracePath(filePath: string): string {\n return normalizePath(filePath)\n .replace('file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,CAAA;AAC9B,CAAC","sourcesContent":["import {renderFatalError} from './ui.js'\nimport {OutputMessage, stringifyMessage, TokenizedString} from '../../public/node/output.js'\nimport {normalizePath} from '../../public/node/path.js'\nimport {InlineToken, TokenItem} from '../../private/node/ui/components/TokenizedText.js'\nimport {Errors} from '@oclif/core'\n\nexport {ExtendableError} from 'ts-error'\n\nenum FatalErrorType {\n Abort,\n AbortSilent,\n Bug,\n}\n\nexport class CancelExecution extends Error {}\n\n/**\n * A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.\n * There shouldn't be code that catches fatal errors.\n */\nexport abstract class FatalError extends Error {\n tryMessage: TokenItem | null\n type: FatalErrorType\n nextSteps?: TokenItem<InlineToken>[]\n /**\n * Creates a new FatalError error.\n *\n * @param message - The error message.\n * @param type - The type of fatal error.\n * @param tryMessage - The message that recommends next steps to the user.\n * You can pass a string a {@link TokenizedString} or a {@link TokenItem}\n * if you need to style the message inside the error Banner component.\n * @param nextSteps - Message to show as \"next steps\" with suggestions to solve the issue.\n */\n constructor(\n message: OutputMessage,\n type: FatalErrorType,\n tryMessage: TokenItem | OutputMessage | null = null,\n nextSteps?: TokenItem<InlineToken>[],\n ) {\n super(stringifyMessage(message))\n\n if (tryMessage) {\n if (tryMessage instanceof TokenizedString) {\n this.tryMessage = stringifyMessage(tryMessage)\n } else {\n this.tryMessage = tryMessage\n }\n } else {\n this.tryMessage = null\n }\n\n this.type = type\n this.nextSteps = nextSteps\n }\n}\n\n/**\n * An abort error is a fatal error that shouldn't be reported as a bug.\n * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer.\n */\nexport class AbortError extends FatalError {\n nextSteps?: TokenItem<InlineToken>[]\n constructor(\n message: OutputMessage,\n tryMessage: TokenItem | OutputMessage | null = null,\n nextSteps?: TokenItem<InlineToken>[],\n ) {\n super(message, FatalErrorType.Abort, tryMessage, nextSteps)\n }\n}\n\n/**\n * An external error is similar to Abort but has extra command and args attributes.\n * This is useful to represent errors coming from external commands, usually executed by execa.\n */\nexport class ExternalError extends FatalError {\n command: string\n args: string[]\n\n constructor(\n message: OutputMessage,\n command: string,\n args: string[],\n tryMessage: TokenItem | OutputMessage | null = null,\n ) {\n super(message, FatalErrorType.Abort, tryMessage)\n this.command = command\n this.args = args\n }\n}\n\nexport class AbortSilentError extends FatalError {\n constructor() {\n super('', FatalErrorType.AbortSilent)\n }\n}\n\n/**\n * A bug error is an error that represents a bug and therefore should be reported.\n */\nexport class BugError extends FatalError {\n constructor(message: OutputMessage, tryMessage: TokenItem | null = null) {\n super(message, FatalErrorType.Bug, tryMessage)\n }\n}\n\n/**\n * A function that handles errors that blow up in the CLI.\n *\n * @param error - Error to be handled.\n * @returns A promise that resolves with the error passed.\n */\nexport async function handler(error: unknown): Promise<unknown> {\n let fatal: FatalError\n if (isFatal(error)) {\n fatal = error\n } else if (typeof error === 'string') {\n fatal = new BugError(error)\n } else if (error instanceof Error) {\n fatal = new BugError(error.message)\n fatal.stack = error.stack\n } else {\n // errors can come in all shapes and sizes...\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const maybeError = error as any\n fatal = new BugError(maybeError?.message ?? 'Unknown error')\n if (maybeError?.stack) {\n fatal.stack = maybeError?.stack\n }\n }\n\n renderFatalError(fatal)\n return Promise.resolve(error)\n}\n\n/**\n * A function that maps an error to an Abort with the stack trace when coming from the CLI.\n *\n * @param error - Error to be mapped.\n * @returns A promise that resolves with the new error object.\n */\nexport function errorMapper(error: unknown): Promise<unknown> {\n if (error instanceof Errors.CLIError) {\n const mappedError = new AbortError(error.message)\n mappedError.stack = error.stack\n return Promise.resolve(mappedError)\n } else {\n return Promise.resolve(error)\n }\n}\n\n/**\n * A function that checks if an error is a fatal one.\n *\n * @param error - Error to be checked.\n * @returns A boolean indicating if the error is a fatal one.\n */\nfunction isFatal(error: unknown): error is FatalError {\n try {\n return Object.prototype.hasOwnProperty.call(error, 'type')\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * A function that checks if an error should be reported.\n *\n * @param error - Error to be checked.\n * @returns A boolean indicating if the error should be reported.\n */\nexport function shouldReportError(error: unknown): boolean {\n if (!isFatal(error)) {\n return true\n }\n if (error.type === FatalErrorType.Bug) {\n return true\n }\n return false\n}\n\n/**\n * Stack traces usually have file:// - we strip that and also remove the Windows drive designation.\n *\n * @param filePath - Path to be cleaned.\n * @returns The cleaned path.\n */\nexport function cleanSingleStackTracePath(filePath: string): string {\n return normalizePath(filePath)\n .replace('file:/', '/')\n .replace(/^\\/?[A-Z]:/, '')\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { hasGit, isTerminalInteractive } from './environment/local.js';
1
+ import { hasGit, isTerminalInteractive } from './context/local.js';
2
2
  import { appendFileSync } from './fs.js';
3
3
  import { AbortError } from './error.js';
4
4
  import { cwd } from './path.js';
@@ -1 +1 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/public/node/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AACtC,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,GAAoF,MAAM,YAAY,CAAA;AAE7G;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,SAAiB,EAAE,aAAa,GAAG,MAAM;IACrF,WAAW,CAAC,aAAa,CAAA,kCAAkC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC5F,MAAM,yBAAyB,EAAE,CAAA;IACjC,gHAAgH;IAChH,6DAA6D;IAC7D,aAAa;IACb,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,CAAA;IAC3B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J,CAAA;KACF;AACH,CAAC;AAED,MAAM,OAAO,wBAAyB,SAAQ,UAAU;CAAG;AAC3D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,SAAkB;IAC/D,6DAA6D;IAC7D,aAAa;IACb,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAC,OAAO,EAAE,SAAS,EAAC,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE;QACpD,MAAM,IAAI,wBAAwB,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC,yBAAyB,CAAC,CAAA;KACrG;AACH,CAAC","sourcesContent":["import {hasGit, isTerminalInteractive} from './environment/local.js'\nimport {appendFileSync} from './fs.js'\nimport {AbortError} from './error.js'\nimport {cwd} from './path.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport git, {TaskOptions, SimpleGitProgressEvent, DefaultLogFields, ListLogLine, SimpleGit} from 'simple-git'\n\n/**\n * Initialize a git repository at the given directory.\n *\n * @param directory - The directory where the git repository will be initialized.\n * @param initialBranch - The name of the initial branch.\n */\nexport async function initializeGitRepository(directory: string, initialBranch = 'main'): Promise<void> {\n outputDebug(outputContent`Initializing git repository at ${outputToken.path(directory)}...`)\n await ensureGitIsPresentOrAbort()\n // We use init and checkout instead of `init --initial-branch` because the latter is only supported in git 2.28+\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const repo = git(directory)\n await repo.init()\n await repo.checkoutLocalBranch(initialBranch)\n}\n\n/**\n * Given a Git repository and a list of absolute paths to files contained\n * in the repository, it filters and returns the files that are ignored\n * by the .gitignore.\n *\n * @param directory - The absolute path to the directory containing the files.\n * @param files - The list of files to check against.\n */\nexport async function checkIfIgnoredInGitRepository(directory: string, files: string[]): Promise<string[]> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const repo = git(directory)\n const ignoredLockfile = await repo.checkIgnore(files)\n return ignoredLockfile\n}\n\nexport interface GitIgnoreTemplate {\n [section: string]: string[]\n}\n/**\n * Create a .gitignore file in the given directory.\n *\n * @param directory - The directory where the .gitignore file will be created.\n * @param template - The template to use to create the .gitignore file.\n */\nexport function createGitIgnore(directory: string, template: GitIgnoreTemplate): void {\n outputDebug(outputContent`Creating .gitignore at ${outputToken.path(directory)}...`)\n const filePath = `${directory}/.gitignore`\n\n let fileContent = ''\n for (const [section, lines] of Object.entries(template)) {\n fileContent += `# ${section}\\n`\n fileContent += `${lines.join('\\n')}\\n\\n`\n }\n\n appendFileSync(filePath, fileContent)\n}\n\n/**\n * Options to use when cloning a git repository.\n *\n * @param repoUrl - The URL of the repository to clone.\n * @param destination - The directory where the repository will be cloned.\n * @param progressUpdater - A function that will be called with the progress of the clone.\n * @param shallow - Whether to clone the repository shallowly.\n * @param latestTag - Whether to clone the latest tag instead of the default branch.\n */\nexport interface GitCloneOptions {\n repoUrl: string\n destination: string\n progressUpdater?: (statusString: string) => void\n shallow?: boolean\n latestTag?: boolean\n}\n/**\n * Clone a git repository.\n *\n * @param cloneOptions - The options to use to clone the repository.\n * @returns A promise that resolves when the clone is complete.\n */\nexport async function downloadGitRepository(cloneOptions: GitCloneOptions): Promise<void> {\n const {repoUrl, destination, progressUpdater, shallow, latestTag} = cloneOptions\n outputDebug(outputContent`Git-cloning repository ${repoUrl} into ${outputToken.path(destination)}...`)\n await ensureGitIsPresentOrAbort()\n const [repository, branch] = repoUrl.split('#')\n const options: TaskOptions = {'--recurse-submodules': null}\n\n if (branch && latestTag) {\n throw new AbortError(\"Error cloning the repository. Git can't clone the latest release with a 'branch'.\")\n }\n if (branch) {\n options['--branch'] = branch\n }\n\n if (shallow && latestTag) {\n throw new AbortError(\n \"Error cloning the repository. Git can't clone the latest release with the 'shallow' property.\",\n )\n }\n if (shallow) {\n options['--depth'] = 1\n }\n\n const progress = ({stage, progress, processed, total}: SimpleGitProgressEvent) => {\n const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`\n if (progressUpdater) progressUpdater(updateString)\n }\n\n const simpleGitOptions = {\n progress,\n ...(!isTerminalInteractive() && {config: ['core.askpass=true']}),\n }\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n await git(simpleGitOptions).clone(repository!, destination, options)\n\n if (latestTag) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const localGitRepository = git(destination)\n const latestTag = await getLocalLatestTag(localGitRepository, repoUrl)\n await localGitRepository.checkout(latestTag)\n }\n } catch (err) {\n if (err instanceof Error) {\n const abortError = new AbortError(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n throw err\n }\n}\n\n/**\n * Get the most recent tag of a local git repository.\n *\n * @param repository - The local git repository.\n * @param repoUrl - The URL of the repository.\n * @returns The most recent tag of the repository.\n */\nasync function getLocalLatestTag(repository: SimpleGit, repoUrl: string): Promise<string> {\n const latest = (await repository.tags()).latest\n\n if (!latest) {\n throw new AbortError(`Couldn't obtain the most recent tag of the repository ${repoUrl}`)\n }\n\n return latest\n}\n\n/**\n * Get the latest commit of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The latest commit of the repository.\n */\nexport async function getLatestGitCommit(directory?: string): Promise<DefaultLogFields & ListLogLine> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const logs = await git({baseDir: directory}).log({\n maxCount: 1,\n })\n if (!logs.latest) {\n throw new AbortError(\n 'Must have at least one commit to run command',\n outputContent`Run ${outputToken.genericShellCommand(\n \"git commit -m 'Initial commit'\",\n )} to create your first commit.`,\n )\n }\n return logs.latest\n}\n\n/**\n * Add all files to the git index from the given directory.\n *\n * @param directory - The directory where the git repository is located.\n * @returns A promise that resolves when the files are added to the index.\n */\nexport async function addAllToGitFromDirectory(directory?: string): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const simpleGit = git({baseDir: directory})\n await simpleGit.raw('add', '--all')\n}\n\nexport interface CreateGitCommitOptions {\n directory?: string\n author?: string\n}\n\n/**\n * Create a git commit.\n *\n * @param message - The message of the commit.\n * @param options - The options to use to create the commit.\n * @returns The hash of the created commit.\n */\nexport async function createGitCommit(message: string, options?: CreateGitCommitOptions): Promise<string> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const simpleGit = git({baseDir: options?.directory})\n\n const commitOptions = options?.author ? {'--author': options.author} : undefined\n const result = await simpleGit.commit(message, commitOptions)\n\n return result.commit\n}\n\n/**\n * Get the HEAD symbolic reference of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The HEAD symbolic reference of the repository.\n */\nexport async function getHeadSymbolicRef(directory?: string): Promise<string> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const ref = await git({baseDir: directory}).raw('symbolic-ref', '-q', 'HEAD')\n if (!ref) {\n throw new AbortError(\n \"Git HEAD can't be detached to run command\",\n outputContent`Run ${outputToken.genericShellCommand(\n 'git checkout [branchName]',\n )} to reattach HEAD or see git ${outputToken.link(\n 'documentation',\n 'https://git-scm.com/book/en/v2/Git-Internals-Git-References',\n )} for more details`,\n )\n }\n return ref.trim()\n}\n\n/**\n * If \"git\" is not present in the environment it throws\n * an abort error.\n */\nexport async function ensureGitIsPresentOrAbort(): Promise<void> {\n if (!(await hasGit())) {\n throw new AbortError(\n `Git is necessary in the environment to continue`,\n outputContent`Install ${outputToken.link(\n 'git',\n 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git',\n )}`,\n )\n }\n}\n\nexport class OutsideGitDirectoryError extends AbortError {}\n/**\n * If command run from outside a .git directory tree\n * it throws an abort error.\n *\n * @param directory - The directory to check.\n */\nexport async function ensureInsideGitDirectory(directory?: string): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (!(await git({baseDir: directory}).checkIsRepo())) {\n throw new OutsideGitDirectoryError(`${outputToken.path(directory || cwd())} is not a Git directory`)\n }\n}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G;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,SAAkB;IACzD,6DAA6D;IAC7D,aAAa;IACb,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,EAAC,OAAO,EAAE,SAAS,EAAC,CAAC,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IAC7E,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,UAAU,CAClB,2CAA2C,EAC3C,aAAa,CAAA,OAAO,WAAW,CAAC,mBAAmB,CACjD,2BAA2B,CAC5B,gCAAgC,WAAW,CAAC,IAAI,CAC/C,eAAe,EACf,6DAA6D,CAC9D,mBAAmB,CACrB,CAAA;KACF;IACD,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,IAAI,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,EAAE;QACrB,MAAM,IAAI,UAAU,CAClB,iDAAiD,EACjD,aAAa,CAAA,WAAW,WAAW,CAAC,IAAI,CACtC,KAAK,EACL,+DAA+D,CAChE,EAAE,CACJ,CAAA;KACF;AACH,CAAC;AAED,MAAM,OAAO,wBAAyB,SAAQ,UAAU;CAAG;AAC3D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,SAAkB;IAC/D,6DAA6D;IAC7D,aAAa;IACb,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAC,OAAO,EAAE,SAAS,EAAC,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE;QACpD,MAAM,IAAI,wBAAwB,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC,yBAAyB,CAAC,CAAA;KACrG;AACH,CAAC","sourcesContent":["import {hasGit, isTerminalInteractive} from './context/local.js'\nimport {appendFileSync} from './fs.js'\nimport {AbortError} from './error.js'\nimport {cwd} from './path.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport git, {TaskOptions, SimpleGitProgressEvent, DefaultLogFields, ListLogLine, SimpleGit} from 'simple-git'\n\n/**\n * Initialize a git repository at the given directory.\n *\n * @param directory - The directory where the git repository will be initialized.\n * @param initialBranch - The name of the initial branch.\n */\nexport async function initializeGitRepository(directory: string, initialBranch = 'main'): Promise<void> {\n outputDebug(outputContent`Initializing git repository at ${outputToken.path(directory)}...`)\n await ensureGitIsPresentOrAbort()\n // We use init and checkout instead of `init --initial-branch` because the latter is only supported in git 2.28+\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const repo = git(directory)\n await repo.init()\n await repo.checkoutLocalBranch(initialBranch)\n}\n\n/**\n * Given a Git repository and a list of absolute paths to files contained\n * in the repository, it filters and returns the files that are ignored\n * by the .gitignore.\n *\n * @param directory - The absolute path to the directory containing the files.\n * @param files - The list of files to check against.\n */\nexport async function checkIfIgnoredInGitRepository(directory: string, files: string[]): Promise<string[]> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const repo = git(directory)\n const ignoredLockfile = await repo.checkIgnore(files)\n return ignoredLockfile\n}\n\nexport interface GitIgnoreTemplate {\n [section: string]: string[]\n}\n/**\n * Create a .gitignore file in the given directory.\n *\n * @param directory - The directory where the .gitignore file will be created.\n * @param template - The template to use to create the .gitignore file.\n */\nexport function createGitIgnore(directory: string, template: GitIgnoreTemplate): void {\n outputDebug(outputContent`Creating .gitignore at ${outputToken.path(directory)}...`)\n const filePath = `${directory}/.gitignore`\n\n let fileContent = ''\n for (const [section, lines] of Object.entries(template)) {\n fileContent += `# ${section}\\n`\n fileContent += `${lines.join('\\n')}\\n\\n`\n }\n\n appendFileSync(filePath, fileContent)\n}\n\n/**\n * Options to use when cloning a git repository.\n *\n * @param repoUrl - The URL of the repository to clone.\n * @param destination - The directory where the repository will be cloned.\n * @param progressUpdater - A function that will be called with the progress of the clone.\n * @param shallow - Whether to clone the repository shallowly.\n * @param latestTag - Whether to clone the latest tag instead of the default branch.\n */\nexport interface GitCloneOptions {\n repoUrl: string\n destination: string\n progressUpdater?: (statusString: string) => void\n shallow?: boolean\n latestTag?: boolean\n}\n/**\n * Clone a git repository.\n *\n * @param cloneOptions - The options to use to clone the repository.\n * @returns A promise that resolves when the clone is complete.\n */\nexport async function downloadGitRepository(cloneOptions: GitCloneOptions): Promise<void> {\n const {repoUrl, destination, progressUpdater, shallow, latestTag} = cloneOptions\n outputDebug(outputContent`Git-cloning repository ${repoUrl} into ${outputToken.path(destination)}...`)\n await ensureGitIsPresentOrAbort()\n const [repository, branch] = repoUrl.split('#')\n const options: TaskOptions = {'--recurse-submodules': null}\n\n if (branch && latestTag) {\n throw new AbortError(\"Error cloning the repository. Git can't clone the latest release with a 'branch'.\")\n }\n if (branch) {\n options['--branch'] = branch\n }\n\n if (shallow && latestTag) {\n throw new AbortError(\n \"Error cloning the repository. Git can't clone the latest release with the 'shallow' property.\",\n )\n }\n if (shallow) {\n options['--depth'] = 1\n }\n\n const progress = ({stage, progress, processed, total}: SimpleGitProgressEvent) => {\n const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`\n if (progressUpdater) progressUpdater(updateString)\n }\n\n const simpleGitOptions = {\n progress,\n ...(!isTerminalInteractive() && {config: ['core.askpass=true']}),\n }\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n await git(simpleGitOptions).clone(repository!, destination, options)\n\n if (latestTag) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const localGitRepository = git(destination)\n const latestTag = await getLocalLatestTag(localGitRepository, repoUrl)\n await localGitRepository.checkout(latestTag)\n }\n } catch (err) {\n if (err instanceof Error) {\n const abortError = new AbortError(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n throw err\n }\n}\n\n/**\n * Get the most recent tag of a local git repository.\n *\n * @param repository - The local git repository.\n * @param repoUrl - The URL of the repository.\n * @returns The most recent tag of the repository.\n */\nasync function getLocalLatestTag(repository: SimpleGit, repoUrl: string): Promise<string> {\n const latest = (await repository.tags()).latest\n\n if (!latest) {\n throw new AbortError(`Couldn't obtain the most recent tag of the repository ${repoUrl}`)\n }\n\n return latest\n}\n\n/**\n * Get the latest commit of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The latest commit of the repository.\n */\nexport async function getLatestGitCommit(directory?: string): Promise<DefaultLogFields & ListLogLine> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const logs = await git({baseDir: directory}).log({\n maxCount: 1,\n })\n if (!logs.latest) {\n throw new AbortError(\n 'Must have at least one commit to run command',\n outputContent`Run ${outputToken.genericShellCommand(\n \"git commit -m 'Initial commit'\",\n )} to create your first commit.`,\n )\n }\n return logs.latest\n}\n\n/**\n * Add all files to the git index from the given directory.\n *\n * @param directory - The directory where the git repository is located.\n * @returns A promise that resolves when the files are added to the index.\n */\nexport async function addAllToGitFromDirectory(directory?: string): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const simpleGit = git({baseDir: directory})\n await simpleGit.raw('add', '--all')\n}\n\nexport interface CreateGitCommitOptions {\n directory?: string\n author?: string\n}\n\n/**\n * Create a git commit.\n *\n * @param message - The message of the commit.\n * @param options - The options to use to create the commit.\n * @returns The hash of the created commit.\n */\nexport async function createGitCommit(message: string, options?: CreateGitCommitOptions): Promise<string> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const simpleGit = git({baseDir: options?.directory})\n\n const commitOptions = options?.author ? {'--author': options.author} : undefined\n const result = await simpleGit.commit(message, commitOptions)\n\n return result.commit\n}\n\n/**\n * Get the HEAD symbolic reference of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The HEAD symbolic reference of the repository.\n */\nexport async function getHeadSymbolicRef(directory?: string): Promise<string> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const ref = await git({baseDir: directory}).raw('symbolic-ref', '-q', 'HEAD')\n if (!ref) {\n throw new AbortError(\n \"Git HEAD can't be detached to run command\",\n outputContent`Run ${outputToken.genericShellCommand(\n 'git checkout [branchName]',\n )} to reattach HEAD or see git ${outputToken.link(\n 'documentation',\n 'https://git-scm.com/book/en/v2/Git-Internals-Git-References',\n )} for more details`,\n )\n }\n return ref.trim()\n}\n\n/**\n * If \"git\" is not present in the environment it throws\n * an abort error.\n */\nexport async function ensureGitIsPresentOrAbort(): Promise<void> {\n if (!(await hasGit())) {\n throw new AbortError(\n `Git is necessary in the environment to continue`,\n outputContent`Install ${outputToken.link(\n 'git',\n 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git',\n )}`,\n )\n }\n}\n\nexport class OutsideGitDirectoryError extends AbortError {}\n/**\n * If command run from outside a .git directory tree\n * it throws an abort error.\n *\n * @param directory - The directory to check.\n */\nexport async function ensureInsideGitDirectory(directory?: string): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (!(await git({baseDir: directory}).checkIsRepo())) {\n throw new OutsideGitDirectoryError(`${outputToken.path(directory || cwd())} is not a Git directory`)\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
1
  import { Hook } from '@oclif/core';
2
- export declare const hookPost: Hook.Postrun;
2
+ export declare const hook: Hook.Postrun;
@@ -1,7 +1,7 @@
1
1
  import { reportAnalyticsEvent } from '../analytics.js';
2
2
  import { outputDebug } from '../../../public/node/output.js';
3
3
  // This hook is called after each successful command run. More info: https://oclif.io/docs/hooks
4
- export const hookPost = async ({ config, Command }) => {
4
+ export const hook = async ({ config, Command }) => {
5
5
  await reportAnalyticsEvent({ config });
6
6
  const command = Command?.id?.replace(/:/g, ' ');
7
7
  outputDebug(`Completed command ${command}`);
@@ -1 +1 @@
1
- {"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/postrun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAA;AAG1D,gGAAgG;AAChG,MAAM,CAAC,MAAM,QAAQ,GAAiB,KAAK,EAAE,EAAC,MAAM,EAAE,OAAO,EAAC,EAAE,EAAE;IAChE,MAAM,oBAAoB,CAAC,EAAC,MAAM,EAAC,CAAC,CAAA;IACpC,MAAM,OAAO,GAAG,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAC/C,WAAW,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAA;AAC7C,CAAC,CAAA","sourcesContent":["import {reportAnalyticsEvent} from '../analytics.js'\nimport {outputDebug} from '../../../public/node/output.js'\nimport {Hook} from '@oclif/core'\n\n// This hook is called after each successful command run. More info: https://oclif.io/docs/hooks\nexport const hookPost: Hook.Postrun = async ({config, Command}) => {\n await reportAnalyticsEvent({config})\n const command = Command?.id?.replace(/:/g, ' ')\n outputDebug(`Completed command ${command}`)\n}\n"]}
1
+ {"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/postrun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAA;AAG1D,gGAAgG;AAChG,MAAM,CAAC,MAAM,IAAI,GAAiB,KAAK,EAAE,EAAC,MAAM,EAAE,OAAO,EAAC,EAAE,EAAE;IAC5D,MAAM,oBAAoB,CAAC,EAAC,MAAM,EAAC,CAAC,CAAA;IACpC,MAAM,OAAO,GAAG,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAC/C,WAAW,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAA;AAC7C,CAAC,CAAA","sourcesContent":["import {reportAnalyticsEvent} from '../analytics.js'\nimport {outputDebug} from '../../../public/node/output.js'\nimport {Hook} from '@oclif/core'\n\n// This hook is called after each successful command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Postrun = async ({config, Command}) => {\n await reportAnalyticsEvent({config})\n const command = Command?.id?.replace(/:/g, ' ')\n outputDebug(`Completed command ${command}`)\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import FormData from 'form-data';
2
2
  import nodeFetch, { RequestInfo, RequestInit } from 'node-fetch';
3
3
  export { createApp, createRouter, IncomingMessage, ServerResponse, CompatibilityEvent, createError, send, sendError, sendRedirect, H3Error, } from 'h3';
4
+ export { FetchError } from 'node-fetch';
4
5
  /**
5
6
  * Create a new FormData object.
6
7
  *
@@ -6,6 +6,7 @@ import FormData from 'form-data';
6
6
  import nodeFetch from 'node-fetch';
7
7
  import { performance } from 'perf_hooks';
8
8
  export { createApp, createRouter, createError, send, sendError, sendRedirect, H3Error, } from 'h3';
9
+ export { FetchError } from 'node-fetch';
9
10
  /**
10
11
  * Create a new FormData object.
11
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/public/node/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,qBAAqB,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AACxF,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAC,MAAM,mCAAmC,CAAA;AAClG,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACtE,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,SAAqC,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAEtC,OAAO,EACL,SAAS,EACT,YAAY,EAIZ,WAAW,EACX,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,OAAO,GACR,MAAM,IAAI,CAAA;AAEX;;;;GAIG;AACH,MAAM,UAAU,QAAQ;IACtB,OAA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,EAAE,CAAC,CAAA;IAE1C,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE;YAChC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;SACvB;QAED,MAAM,IAAI,GAAG,qBAAqB,CAAC,EAAE,CAAC,CAAA;QAEtC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACrB,IAAI,CAAC,KAAK,EAAE,CAAA;YACZ,OAAO,CAAC,EAAE,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACvB,cAAc,CAAC,EAAE,CAAC,CAAA;YAClB,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,GAAG,EAAE,EAAC,QAAQ,EAAE,QAAQ,EAAC,CAAC;aACjC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,cAAc,CAAC,EAAE,CAAC,CAAA;YAClB,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {dirname} from './path.js'\nimport {createFileWriteStream, fileExistsSync, mkdirSync, unlinkFileSync} from './fs.js'\nimport {buildHeaders, httpsAgent, sanitizedHeadersOutput} from '../../private/node/api/headers.js'\nimport {outputContent, outputDebug} from '../../public/node/output.js'\nimport FormData from 'form-data'\nimport nodeFetch, {RequestInfo, RequestInit} from 'node-fetch'\nimport {performance} from 'perf_hooks'\n\nexport {\n createApp,\n createRouter,\n IncomingMessage,\n ServerResponse,\n CompatibilityEvent,\n createError,\n send,\n sendError,\n sendRedirect,\n H3Error,\n} from 'h3'\n\n/**\n * Create a new FormData object.\n *\n * @returns A FormData object.\n */\nexport function formData(): FormData {\n return new FormData()\n}\n\nexport type Response = ReturnType<typeof nodeFetch>\n\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. Spin).\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function shopifyFetch(url: RequestInfo, init?: RequestInit): Response {\n const options: RequestInit = {\n ...(init ?? {}),\n headers: {\n ...(await buildHeaders()),\n ...(init?.headers ?? {}),\n },\n }\n\n outputDebug(outputContent`\nSending ${options.method ?? 'GET'} request to URL ${url.toString()} and headers:\n${sanitizedHeadersOutput((options?.headers ?? {}) as {[header: string]: string})}\n`)\n const t0 = performance.now()\n const response = await nodeFetch(url, {...init, agent: await httpsAgent()})\n const t1 = performance.now()\n outputDebug(`Request to ${url.toString()} completed with status ${response.status} in ${Math.round(t1 - t0)} ms`)\n return response\n}\n\n/**\n * Download a file from a URL to a local path.\n *\n * @param url - The URL to download from.\n * @param to - The local path to download to.\n * @returns - A promise that resolves with the local path.\n */\nexport function downloadFile(url: string, to: string): Promise<string> {\n outputDebug(`Downloading ${url} to ${to}`)\n\n return new Promise<string>((resolve, reject) => {\n if (!fileExistsSync(dirname(to))) {\n mkdirSync(dirname(to))\n }\n\n const file = createFileWriteStream(to)\n\n file.on('finish', () => {\n file.close()\n resolve(to)\n })\n\n file.on('error', (err) => {\n unlinkFileSync(to)\n reject(err)\n })\n\n nodeFetch(url, {redirect: 'follow'})\n .then((res) => {\n res.body?.pipe(file)\n })\n .catch((err) => {\n unlinkFileSync(to)\n reject(err)\n })\n })\n}\n"]}
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/public/node/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,qBAAqB,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AACxF,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAC,MAAM,mCAAmC,CAAA;AAClG,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACtE,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,SAAqC,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAEtC,OAAO,EACL,SAAS,EACT,YAAY,EAIZ,WAAW,EACX,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,OAAO,GACR,MAAM,IAAI,CAAA;AAEX,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AAErC;;;;GAIG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,IAAI,QAAQ,EAAE,CAAA;AACvB,CAAC;AAID;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IAC9D,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAgB,EAAE,IAAkB;IACrE,MAA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ACrB,IAAI,CAAC,KAAK,EAAE,CAAA;YACZ,OAAO,CAAC,EAAE,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACvB,cAAc,CAAC,EAAE,CAAC,CAAA;YAClB,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,GAAG,EAAE,EAAC,QAAQ,EAAE,QAAQ,EAAC,CAAC;aACjC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,cAAc,CAAC,EAAE,CAAC,CAAA;YAClB,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {dirname} from './path.js'\nimport {createFileWriteStream, fileExistsSync, mkdirSync, unlinkFileSync} from './fs.js'\nimport {buildHeaders, httpsAgent, sanitizedHeadersOutput} from '../../private/node/api/headers.js'\nimport {outputContent, outputDebug} from '../../public/node/output.js'\nimport FormData from 'form-data'\nimport nodeFetch, {RequestInfo, RequestInit} from 'node-fetch'\nimport {performance} from 'perf_hooks'\n\nexport {\n createApp,\n createRouter,\n IncomingMessage,\n ServerResponse,\n CompatibilityEvent,\n createError,\n send,\n sendError,\n sendRedirect,\n H3Error,\n} from 'h3'\n\nexport {FetchError} from 'node-fetch'\n\n/**\n * Create a new FormData object.\n *\n * @returns A FormData object.\n */\nexport function formData(): FormData {\n return new FormData()\n}\n\nexport type Response = ReturnType<typeof nodeFetch>\n\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. Spin).\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function shopifyFetch(url: RequestInfo, init?: RequestInit): Response {\n const options: RequestInit = {\n ...(init ?? {}),\n headers: {\n ...(await buildHeaders()),\n ...(init?.headers ?? {}),\n },\n }\n\n outputDebug(outputContent`\nSending ${options.method ?? 'GET'} request to URL ${url.toString()} and headers:\n${sanitizedHeadersOutput((options?.headers ?? {}) as {[header: string]: string})}\n`)\n const t0 = performance.now()\n const response = await nodeFetch(url, {...init, agent: await httpsAgent()})\n const t1 = performance.now()\n outputDebug(`Request to ${url.toString()} completed with status ${response.status} in ${Math.round(t1 - t0)} ms`)\n return response\n}\n\n/**\n * Download a file from a URL to a local path.\n *\n * @param url - The URL to download from.\n * @param to - The local path to download to.\n * @returns - A promise that resolves with the local path.\n */\nexport function downloadFile(url: string, to: string): Promise<string> {\n outputDebug(`Downloading ${url} to ${to}`)\n\n return new Promise<string>((resolve, reject) => {\n if (!fileExistsSync(dirname(to))) {\n mkdirSync(dirname(to))\n }\n\n const file = createFileWriteStream(to)\n\n file.on('finish', () => {\n file.close()\n resolve(to)\n })\n\n file.on('error', (err) => {\n unlinkFileSync(to)\n reject(err)\n })\n\n nodeFetch(url, {redirect: 'follow'})\n .then((res) => {\n res.body?.pipe(file)\n })\n .catch((err) => {\n unlinkFileSync(to)\n reject(err)\n })\n })\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { sendErrorToBugsnag } from './error-handler.js';
2
- import { isUnitTest } from './environment/local.js';
2
+ import { isUnitTest } from './context/local.js';
3
3
  /**
4
4
  * Get the error handling strategy for metadata.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/public/node/metadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AAcjD;;;;GAIG;AACH,SAAS,gCAAgC;IACvC,IAAI,UAAU,EAAE,EAAE;QAChB,OAAO,QAAQ,CAAA;KAChB;IACD,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAgBD;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B;IAI5C,MAAM,GAAG,GAA+D;QACtE,SAAS,EAAE,EAAE;QACb,MAAM,EAAE,EAAE;KACX,CAAA;IACD,MAAM,SAAS,GAAG,CAAC,IAAsB,EAAE,EAAE;QAC3C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACjC,CAAC,CAAA;IACD,MAAM,YAAY,GAAG,CAAC,IAAyB,EAAE,EAAE;QACjD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;IACpC,CAAC,CAAA;IAED,MAAM,WAAW,GAAG,KAAK,EACvB,KAAiC,EACjC,KAAyB,EACzB,OAA8B,EAC9B,EAAE;QACF,MAAM,aAAa,GAAG,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;QACvF,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;YAC3B,MAAM,IAAI,GAAG,MAAM,KAAK,EAAE,CAAA;YAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QACb,CAAC,CAAA;QAED,IAAI,aAAa,KAAK,QAAQ,EAAE;YAC9B,MAAM,SAAS,EAAE,CAAA;SAClB;aAAM;YACL,IAAI;gBACF,MAAM,SAAS,EAAE,CAAA;gBACjB,yFAAyF;aAC1F;YAAC,OAAO,KAAU,EAAE;gBACnB,MAAM,kBAAkB,CAAC,KAAK,CAAC,CAAA;aAChC;SACF;IACH,CAAC,CAAA;IAED,OAAO;QACL,oBAAoB,EAAE,GAAG,EAAE;YACzB,OAAO,EAAC,GAAG,GAAG,CAAC,MAAM,EAAC,CAAA;QACxB,CAAC;QACD,uBAAuB,EAAE,GAAG,EAAE;YAC5B,OAAO,EAAC,GAAG,GAAG,CAAC,SAAS,EAAC,CAAA;QAC3B,CAAC;QACD,iBAAiB,EAAE,KAAK,EAAE,OAAiC,EAAE,UAAiC,MAAM,EAAE,EAAE;YACtG,OAAO,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACjD,CAAC;QACD,oBAAoB,EAAE,KAAK,EAAE,OAAoC,EAAE,UAAiC,MAAM,EAAE,EAAE;YAC5G,OAAO,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;KACF,CAAA;AACH,CAAC;AAOD,MAAM,QAAQ,GAAG,8BAA8B,EAU5C,CAAA;AAEH,MAAM,CAAC,MAAM,EAAC,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,oBAAoB,EAAC,GAAG,QAAQ,CAAA","sourcesContent":["import {MonorailEventPublic} from './monorail.js'\nimport {sendErrorToBugsnag} from './error-handler.js'\nimport {isUnitTest} from './environment/local.js'\nimport {PickByPrefix} from '../common/ts/pick-by-prefix.js'\nimport {AnyJson} from '../../private/common/json.js'\n\ntype ProvideMetadata<T> = () => Partial<T> | Promise<Partial<T>>\n\ntype MetadataErrorHandling =\n // Mute & report errors in production, throw them whilst testing\n | 'auto'\n // Errors are not reported to the user and do not stop execution, but they are reported to Bugsnag\n | 'mute-and-report'\n // Errors are not caught and will bubble out as normal\n | 'bubble'\n\n/**\n * Get the error handling strategy for metadata.\n *\n * @returns 'mute-and-report' in production, 'bubble' in tests.\n */\nfunction getMetadataErrorHandlingStrategy(): 'mute-and-report' | 'bubble' {\n if (isUnitTest()) {\n return 'bubble'\n }\n return 'mute-and-report'\n}\n\nexport interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive extends AnyJson> {\n /** Add some public metadata -- this should not contain any PII. */\n addPublicMetadata: (getData: ProvideMetadata<TPublic>, onError?: MetadataErrorHandling) => Promise<void>\n /** Add some potentially sensitive metadata -- this may include PII, but unnecessary data should never be tracked (this is a good fit for command args for instance). */\n addSensitiveMetadata: (getData: ProvideMetadata<TSensitive>, onError?: MetadataErrorHandling) => Promise<void>\n /** Get a snapshot of the tracked public data. */\n getAllPublicMetadata: () => Partial<TPublic>\n /** Get a snapshot of the tracked sensitive data. */\n getAllSensitiveMetadata: () => Partial<TSensitive>\n}\n\nexport type PublicSchema<T> = T extends RuntimeMetadataManager<infer TPublic, infer _TSensitive> ? TPublic : never\nexport type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic, infer TSensitive> ? TSensitive : never\n\n/**\n * Creates a container for metadata collected at runtime.\n * The container provides async-safe functions for extracting the gathered metadata, and for setting it.\n *\n * @returns A container for the metadata.\n */\nexport function createRuntimeMetadataContainer<\n TPublic extends AnyJson,\n TSensitive extends AnyJson = {[key: string]: never},\n>(): RuntimeMetadataManager<TPublic, TSensitive> {\n const raw: {sensitive: Partial<TSensitive>; public: Partial<TPublic>} = {\n sensitive: {},\n public: {},\n }\n const addPublic = (data: Partial<TPublic>) => {\n Object.assign(raw.public, data)\n }\n const addSensitive = (data: Partial<TSensitive>) => {\n Object.assign(raw.sensitive, data)\n }\n\n const addMetadata = async <T>(\n addFn: (data: Partial<T>) => void,\n getFn: ProvideMetadata<T>,\n onError: MetadataErrorHandling,\n ) => {\n const errorHandling = onError === 'auto' ? getMetadataErrorHandlingStrategy() : onError\n const getAndSet = async () => {\n const data = await getFn()\n addFn(data)\n }\n\n if (errorHandling === 'bubble') {\n await getAndSet()\n } else {\n try {\n await getAndSet()\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (error: any) {\n await sendErrorToBugsnag(error)\n }\n }\n }\n\n return {\n getAllPublicMetadata: () => {\n return {...raw.public}\n },\n getAllSensitiveMetadata: () => {\n return {...raw.sensitive}\n },\n addPublicMetadata: async (getData: ProvideMetadata<TPublic>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addPublic, getData, onError)\n },\n addSensitiveMetadata: async (getData: ProvideMetadata<TSensitive>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addSensitive, getData, onError)\n },\n }\n}\n\n// We want to track anything that ends up getting sent to monorail as `cmd_all_*` and\n// `cmd_app_*`\ntype CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_app_'>\n\nconst coreData = createRuntimeMetadataContainer<\n CmdFieldsFromMonorail,\n {\n commandStartOptions: {\n startTime: number\n startCommand: string\n startTopic?: string\n startArgs: string[]\n }\n }\n>()\n\nexport const {getAllPublicMetadata, getAllSensitiveMetadata, addPublicMetadata, addSensitiveMetadata} = coreData\n\nexport type Public = PublicSchema<typeof coreData>\nexport type Sensitive = SensitiveSchema<typeof coreData>\n"]}
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/public/node/metadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAA;AAc7C;;;;GAIG;AACH,SAAS,gCAAgC;IACvC,IAAI,UAAU,EAAE,EAAE;QAChB,OAAO,QAAQ,CAAA;KAChB;IACD,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAgBD;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B;IAI5C,MAAM,GAAG,GAA+D;QACtE,SAAS,EAAE,EAAE;QACb,MAAM,EAAE,EAAE;KACX,CAAA;IACD,MAAM,SAAS,GAAG,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C,MAAM,EAAE,EAAE;YAC5G,OAAO,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;KACF,CAAA;AACH,CAAC;AAOD,MAAM,QAAQ,GAAG,8BAA8B,EAU5C,CAAA;AAEH,MAAM,CAAC,MAAM,EAAC,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,oBAAoB,EAAC,GAAG,QAAQ,CAAA","sourcesContent":["import {MonorailEventPublic} from './monorail.js'\nimport {sendErrorToBugsnag} from './error-handler.js'\nimport {isUnitTest} from './context/local.js'\nimport {PickByPrefix} from '../common/ts/pick-by-prefix.js'\nimport {AnyJson} from '../../private/common/json.js'\n\ntype ProvideMetadata<T> = () => Partial<T> | Promise<Partial<T>>\n\ntype MetadataErrorHandling =\n // Mute & report errors in production, throw them whilst testing\n | 'auto'\n // Errors are not reported to the user and do not stop execution, but they are reported to Bugsnag\n | 'mute-and-report'\n // Errors are not caught and will bubble out as normal\n | 'bubble'\n\n/**\n * Get the error handling strategy for metadata.\n *\n * @returns 'mute-and-report' in production, 'bubble' in tests.\n */\nfunction getMetadataErrorHandlingStrategy(): 'mute-and-report' | 'bubble' {\n if (isUnitTest()) {\n return 'bubble'\n }\n return 'mute-and-report'\n}\n\nexport interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive extends AnyJson> {\n /** Add some public metadata -- this should not contain any PII. */\n addPublicMetadata: (getData: ProvideMetadata<TPublic>, onError?: MetadataErrorHandling) => Promise<void>\n /** Add some potentially sensitive metadata -- this may include PII, but unnecessary data should never be tracked (this is a good fit for command args for instance). */\n addSensitiveMetadata: (getData: ProvideMetadata<TSensitive>, onError?: MetadataErrorHandling) => Promise<void>\n /** Get a snapshot of the tracked public data. */\n getAllPublicMetadata: () => Partial<TPublic>\n /** Get a snapshot of the tracked sensitive data. */\n getAllSensitiveMetadata: () => Partial<TSensitive>\n}\n\nexport type PublicSchema<T> = T extends RuntimeMetadataManager<infer TPublic, infer _TSensitive> ? TPublic : never\nexport type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic, infer TSensitive> ? TSensitive : never\n\n/**\n * Creates a container for metadata collected at runtime.\n * The container provides async-safe functions for extracting the gathered metadata, and for setting it.\n *\n * @returns A container for the metadata.\n */\nexport function createRuntimeMetadataContainer<\n TPublic extends AnyJson,\n TSensitive extends AnyJson = {[key: string]: never},\n>(): RuntimeMetadataManager<TPublic, TSensitive> {\n const raw: {sensitive: Partial<TSensitive>; public: Partial<TPublic>} = {\n sensitive: {},\n public: {},\n }\n const addPublic = (data: Partial<TPublic>) => {\n Object.assign(raw.public, data)\n }\n const addSensitive = (data: Partial<TSensitive>) => {\n Object.assign(raw.sensitive, data)\n }\n\n const addMetadata = async <T>(\n addFn: (data: Partial<T>) => void,\n getFn: ProvideMetadata<T>,\n onError: MetadataErrorHandling,\n ) => {\n const errorHandling = onError === 'auto' ? getMetadataErrorHandlingStrategy() : onError\n const getAndSet = async () => {\n const data = await getFn()\n addFn(data)\n }\n\n if (errorHandling === 'bubble') {\n await getAndSet()\n } else {\n try {\n await getAndSet()\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (error: any) {\n await sendErrorToBugsnag(error)\n }\n }\n }\n\n return {\n getAllPublicMetadata: () => {\n return {...raw.public}\n },\n getAllSensitiveMetadata: () => {\n return {...raw.sensitive}\n },\n addPublicMetadata: async (getData: ProvideMetadata<TPublic>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addPublic, getData, onError)\n },\n addSensitiveMetadata: async (getData: ProvideMetadata<TSensitive>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addSensitive, getData, onError)\n },\n }\n}\n\n// We want to track anything that ends up getting sent to monorail as `cmd_all_*` and\n// `cmd_app_*`\ntype CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_app_'>\n\nconst coreData = createRuntimeMetadataContainer<\n CmdFieldsFromMonorail,\n {\n commandStartOptions: {\n startTime: number\n startCommand: string\n startTopic?: string\n startArgs: string[]\n }\n }\n>()\n\nexport const {getAllPublicMetadata, getAllSensitiveMetadata, addPublicMetadata, addSensitiveMetadata} = coreData\n\nexport type Public = PublicSchema<typeof coreData>\nexport type Sensitive = SensitiveSchema<typeof coreData>\n"]}
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-console */
2
- import { isUnitTest, isVerbose } from './environment/local.js';
2
+ import { isUnitTest, isVerbose } from './context/local.js';
3
3
  import colors from './colors.js';
4
4
  import { ColorContentToken, CommandContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken, } from '../../private/node/content-tokens.js';
5
5
  import stripAnsi from 'strip-ansi';
@@ -1 +1 @@
1
- {"version":3,"file":"output.js","sourceRoot":"","sources":["../../../src/public/node/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAE5D,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EAEnB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,GACvB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,SAAS,MAAM,YAAY,CAAA;AAElC,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAA;AAG/B,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,YAAY,CAAA;AAI/C,MAAM,OAAO,eAAe;IAE1B,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AAID,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,GAAG,CAAC,KAAa;QACf,OAA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O,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AACjE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAAsD,EACtD,OAAe;IAEf,MAAM,cAAc,GAAG,cAAc,OAAO,aAAa,CAAA;IACzD,IAAI,CAAC,cAAc,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,cAAc,CAAA;IAE1E,MAAM,aAAa,GAAG,WAAW,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;IACtF,OAAO,aAAa,CAAA,GAAG,cAAc,QAAQ,aAAa,EAAE,CAAC,KAAK,CAAA;AACpE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,IAAY;IACvD,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/E,OAAO,aAAa,CAAA,GAAG,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AAC7E,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport {PackageManager} from './node-package-manager.js'\nimport colors from './colors.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from '../../private/node/content-tokens.js'\nimport stripAnsi from 'strip-ansi'\nimport {AbortSignal} from '@shopify/cli-kit/node/abort'\nimport {Writable} from 'stream'\nimport type {Change} from 'diff'\n\nexport {default as logUpdate} from 'log-update'\n\nexport type Logger = Writable | ((message: string) => void)\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type OutputMessage = string | TokenizedString\n\nexport const outputToken = {\n raw(value: string): RawContentToken {\n return new RawContentToken(value)\n },\n genericShellCommand(value: OutputMessage): CommandContentToken {\n return new CommandContentToken(value)\n },\n json(value: unknown): JsonContentToken {\n return new JsonContentToken(value)\n },\n path(value: OutputMessage): PathContentToken {\n return new PathContentToken(value)\n },\n link(value: OutputMessage, link: string): LinkContentToken {\n return new LinkContentToken(value, link)\n },\n heading(value: OutputMessage): HeadingContentToken {\n return new HeadingContentToken(value)\n },\n subheading(value: OutputMessage): SubHeadingContentToken {\n return new SubHeadingContentToken(value)\n },\n italic(value: OutputMessage): ItalicContentToken {\n return new ItalicContentToken(value)\n },\n errorText(value: OutputMessage): ErrorContentToken {\n return new ErrorContentToken(value)\n },\n cyan(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.magenta)\n },\n green(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript(packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]): CommandContentToken {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs))\n },\n successIcon(): ColorContentToken {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon(): ErrorContentToken {\n return new ErrorContentToken('✖')\n },\n linesDiff(value: Change[]): LinesDiffContentToken {\n return new LinesDiffContentToken(value)\n },\n}\n\n/**\n * Given a command and its arguments, it formats it depending on the package manager.\n *\n * @param packageManager - The package manager to use (pnpm, npm, yarn).\n * @param scriptName - The name of the script to run.\n * @param scriptArgs - The arguments to pass to the script.\n * @returns The formatted command.\n */\nexport function formatPackageManagerCommand(\n packageManager: PackageManager,\n scriptName: string,\n ...scriptArgs: string[]\n): string {\n switch (packageManager) {\n case 'pnpm':\n case 'yarn': {\n const pieces = [packageManager, scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'npm': {\n const pieces = ['npm', 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\n/**\n * Creates a tokenized string from an array of strings and tokens.\n *\n * @param strings - The strings to join.\n * @param keys - Array of tokens or strings to join.\n * @returns The tokenized string.\n */\nexport function outputContent(\n strings: TemplateStringsArray,\n ...keys: (ContentToken<unknown> | string)[]\n): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]!\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels. */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n *\n * @param level - The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nfunction logLevelValue(level: LogLevel): number {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n * It returns the current log level (debug or info).\n *\n * @returns The log level set by the user.\n */\nfunction currentLogLevel(): LogLevel {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\n/**\n * It checks if the message should be outputted or not.\n *\n * @param logLevel - The desired log level for the message.\n * @returns True if the message should be outputted, false otherwise.\n */\nfunction shouldOutput(logLevel: LogLevel): boolean {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n *\n * @param key - The key of the log.\n * @param content - The content of the log.\n */\nexport function collectLog(key: string, content: OutputMessage): void {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = (): void => {\n // console.log('clearCollectLogs')\n collectedLogs = {}\n // console.log(collectedLogs)\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputInfo(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputSuccess(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputCompleted(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputDebug(content: OutputMessage, logger: Logger = consoleLog): void {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, `${new Date().toISOString()}: ${message}`)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputWarn(content: OutputMessage, logger: Logger = consoleWarn): void {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport function outputNewline(): void {\n console.log()\n}\n\n/**\n * Converts a Message to string.\n *\n * @param message - The message to convert to string.\n * @returns The string representation of the message.\n */\nexport function stringifyMessage(message: OutputMessage): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nexport interface OutputProcess {\n /**\n * The prefix to include in the logs\n * [vite] Output coming from Vite.\n */\n prefix: string\n /**\n * A callback to invoke the process. Stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\n/**\n * Prints a log message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\n/**\n * Prints an error message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\n/**\n * Prints a warning message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\n/**\n * Writes a message to the appropiated logger.\n *\n * @param logLevel - The log level to use to determine if the message should be output.\n * @param logger - The logger to use to output the message.\n * @param message - The message to output.\n */\nexport function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n if (logger instanceof Writable) {\n logger.write(message)\n } else {\n logger(message)\n }\n }\n}\n\n/**\n * Returns a colored or uncolored version of a message, depending on the environment.\n *\n * @param message - The message to color or not.\n * @returns The message with or without colors.\n */\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\n/**\n * Returns a message without styles (colors or any ANSI escape codes).\n *\n * @param message - The message to remove styles from.\n * @returns The message without styles.\n */\nexport function unstyled(message: string): string {\n return stripAnsi(message)\n}\n\n/**\n * Checks if the console outputs should display colors or not.\n *\n * @returns True if the console outputs should display colors, false otherwise.\n */\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\n/**\n * Generates a message to remind the user to update the CLI.\n *\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to.\n * @returns The message to remind the user to update the CLI.\n */\nexport function getOutputUpdateCLIReminder(\n packageManager: PackageManager | 'unknown' | undefined,\n version: string,\n): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = outputToken.packagejsonScript(packageManager, 'shopify upgrade')\n return outputContent`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string.\n *\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function formatSection(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return outputContent`${outputToken.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../../src/public/node/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAC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AM,CAAC,EAAE,CAAA;IAC/E,OAAO,aAAa,CAAA,GAAG,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AAC7E,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './context/local.js'\nimport {PackageManager} from './node-package-manager.js'\nimport colors from './colors.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from '../../private/node/content-tokens.js'\nimport stripAnsi from 'strip-ansi'\nimport {AbortSignal} from '@shopify/cli-kit/node/abort'\nimport {Writable} from 'stream'\nimport type {Change} from 'diff'\n\nexport {default as logUpdate} from 'log-update'\n\nexport type Logger = Writable | ((message: string) => void)\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type OutputMessage = string | TokenizedString\n\nexport const outputToken = {\n raw(value: string): RawContentToken {\n return new RawContentToken(value)\n },\n genericShellCommand(value: OutputMessage): CommandContentToken {\n return new CommandContentToken(value)\n },\n json(value: unknown): JsonContentToken {\n return new JsonContentToken(value)\n },\n path(value: OutputMessage): PathContentToken {\n return new PathContentToken(value)\n },\n link(value: OutputMessage, link: string): LinkContentToken {\n return new LinkContentToken(value, link)\n },\n heading(value: OutputMessage): HeadingContentToken {\n return new HeadingContentToken(value)\n },\n subheading(value: OutputMessage): SubHeadingContentToken {\n return new SubHeadingContentToken(value)\n },\n italic(value: OutputMessage): ItalicContentToken {\n return new ItalicContentToken(value)\n },\n errorText(value: OutputMessage): ErrorContentToken {\n return new ErrorContentToken(value)\n },\n cyan(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.magenta)\n },\n green(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript(packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]): CommandContentToken {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs))\n },\n successIcon(): ColorContentToken {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon(): ErrorContentToken {\n return new ErrorContentToken('✖')\n },\n linesDiff(value: Change[]): LinesDiffContentToken {\n return new LinesDiffContentToken(value)\n },\n}\n\n/**\n * Given a command and its arguments, it formats it depending on the package manager.\n *\n * @param packageManager - The package manager to use (pnpm, npm, yarn).\n * @param scriptName - The name of the script to run.\n * @param scriptArgs - The arguments to pass to the script.\n * @returns The formatted command.\n */\nexport function formatPackageManagerCommand(\n packageManager: PackageManager,\n scriptName: string,\n ...scriptArgs: string[]\n): string {\n switch (packageManager) {\n case 'pnpm':\n case 'yarn': {\n const pieces = [packageManager, scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'npm': {\n const pieces = ['npm', 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\n/**\n * Creates a tokenized string from an array of strings and tokens.\n *\n * @param strings - The strings to join.\n * @param keys - Array of tokens or strings to join.\n * @returns The tokenized string.\n */\nexport function outputContent(\n strings: TemplateStringsArray,\n ...keys: (ContentToken<unknown> | string)[]\n): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]!\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels. */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n *\n * @param level - The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nfunction logLevelValue(level: LogLevel): number {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n * It returns the current log level (debug or info).\n *\n * @returns The log level set by the user.\n */\nfunction currentLogLevel(): LogLevel {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\n/**\n * It checks if the message should be outputted or not.\n *\n * @param logLevel - The desired log level for the message.\n * @returns True if the message should be outputted, false otherwise.\n */\nfunction shouldOutput(logLevel: LogLevel): boolean {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n *\n * @param key - The key of the log.\n * @param content - The content of the log.\n */\nexport function collectLog(key: string, content: OutputMessage): void {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = (): void => {\n // console.log('clearCollectLogs')\n collectedLogs = {}\n // console.log(collectedLogs)\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputInfo(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputSuccess(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputCompleted(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputDebug(content: OutputMessage, logger: Logger = consoleLog): void {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, `${new Date().toISOString()}: ${message}`)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputWarn(content: OutputMessage, logger: Logger = consoleWarn): void {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport function outputNewline(): void {\n console.log()\n}\n\n/**\n * Converts a Message to string.\n *\n * @param message - The message to convert to string.\n * @returns The string representation of the message.\n */\nexport function stringifyMessage(message: OutputMessage): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nexport interface OutputProcess {\n /**\n * The prefix to include in the logs\n * [vite] Output coming from Vite.\n */\n prefix: string\n /**\n * A callback to invoke the process. Stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\n/**\n * Prints a log message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\n/**\n * Prints an error message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\n/**\n * Prints a warning message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\n/**\n * Writes a message to the appropiated logger.\n *\n * @param logLevel - The log level to use to determine if the message should be output.\n * @param logger - The logger to use to output the message.\n * @param message - The message to output.\n */\nexport function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n if (logger instanceof Writable) {\n logger.write(message)\n } else {\n logger(message)\n }\n }\n}\n\n/**\n * Returns a colored or uncolored version of a message, depending on the environment.\n *\n * @param message - The message to color or not.\n * @returns The message with or without colors.\n */\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\n/**\n * Returns a message without styles (colors or any ANSI escape codes).\n *\n * @param message - The message to remove styles from.\n * @returns The message without styles.\n */\nexport function unstyled(message: string): string {\n return stripAnsi(message)\n}\n\n/**\n * Checks if the console outputs should display colors or not.\n *\n * @returns True if the console outputs should display colors, false otherwise.\n */\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\n/**\n * Generates a message to remind the user to update the CLI.\n *\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to.\n * @returns The message to remind the user to update the CLI.\n */\nexport function getOutputUpdateCLIReminder(\n packageManager: PackageManager | 'unknown' | undefined,\n version: string,\n): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = outputToken.packagejsonScript(packageManager, 'shopify upgrade')\n return outputContent`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string.\n *\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function formatSection(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return outputContent`${outputToken.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
@@ -2,6 +2,7 @@
2
2
  import { AbortSignal } from './abort.js';
3
3
  import { AdminSession } from '../../public/node/session.js';
4
4
  import { Writable } from 'stream';
5
+ export declare const RubyCLIVersion = "2.34.0";
5
6
  interface ExecCLI2Options {
6
7
  adminSession?: AdminSession;
7
8
  storefrontToken?: string;
@@ -2,13 +2,14 @@ import { coerceSemverVersion } from './semver.js';
2
2
  import { platformAndArch } from './os.js';
3
3
  import { captureOutput, exec } from './system.js';
4
4
  import * as file from './fs.js';
5
- import { joinPath, cwd } from './path.js';
5
+ import { joinPath, dirname, cwd } from './path.js';
6
6
  import { AbortError, AbortSilentError } from './error.js';
7
7
  import { pathConstants } from '../../private/node/constants.js';
8
8
  import { outputContent, outputToken } from '../../public/node/output.js';
9
- import { isTruthy } from '../../private/node/environment/utilities.js';
9
+ import { isTruthy } from '../../private/node/context/utilities.js';
10
10
  import { Writable } from 'stream';
11
- const RubyCLIVersion = '2.34.0';
11
+ import { fileURLToPath } from 'url';
12
+ export const RubyCLIVersion = '2.34.0';
12
13
  const ThemeCheckVersion = '1.14.0';
13
14
  const MinBundlerVersion = '2.3.8';
14
15
  const MinRubyVersion = '2.7.5';
@@ -21,7 +22,8 @@ const MinRubyVersion = '2.7.5';
21
22
  * @param options - Options to customize the execution of cli2.
22
23
  */
23
24
  export async function execCLI2(args, options = {}) {
24
- await installCLIDependencies(options.stdout ?? process.stdout);
25
+ const embedded = !isTruthy(process.env.SHOPIFY_CLI_BUNDLED_THEME_CLI) && !process.env.SHOPIFY_CLI_2_0_DIRECTORY;
26
+ await installCLIDependencies(options.stdout ?? process.stdout, embedded);
25
27
  const env = {
26
28
  ...process.env,
27
29
  SHOPIFY_CLI_STOREFRONT_RENDERER_AUTH_TOKEN: options.storefrontToken,
@@ -32,10 +34,12 @@ export async function execCLI2(args, options = {}) {
32
34
  // Bundler uses this Gemfile to understand which gems are available in the
33
35
  // environment. We use this to specify our own Gemfile for CLI2, which exists
34
36
  // outside the user's project directory.
35
- BUNDLE_GEMFILE: joinPath(shopifyCLIDirectory(), 'Gemfile'),
37
+ BUNDLE_GEMFILE: joinPath(await shopifyCLIDirectory(embedded), 'Gemfile'),
36
38
  };
37
39
  try {
38
- await exec(bundleExecutable(), ['exec', 'shopify'].concat(args), {
40
+ const executable = embedded ? await embeddedCLIExecutable() : bundleExecutable();
41
+ const finalArgs = embedded ? args : ['exec', 'shopify'].concat(args);
42
+ await exec(executable, finalArgs, {
39
43
  stdio: 'inherit',
40
44
  cwd: options.directory ?? cwd(),
41
45
  env,
@@ -109,15 +113,17 @@ async function installThemeCheckCLIDependencies(stdout) {
109
113
  * or if we are installing a new version of RubyCLI.
110
114
  *
111
115
  * @param stdout - The Writable stream on which to write the standard output.
116
+ * @param embedded - True when embebbed codebase of CLI should be used.
112
117
  */
113
- async function installCLIDependencies(stdout) {
114
- const exists = await file.fileExists(shopifyCLIDirectory());
118
+ async function installCLIDependencies(stdout, embedded = false) {
119
+ const localCLI = await shopifyCLIDirectory(embedded);
120
+ const exists = await file.fileExists(localCLI);
115
121
  if (!exists)
116
122
  stdout.write('Installing theme dependencies...');
117
- const usingLocalCLI2 = isTruthy(process.env.SHOPIFY_CLI_2_0_DIRECTORY);
123
+ const usingLocalCLI2 = embedded || isTruthy(process.env.SHOPIFY_CLI_2_0_DIRECTORY);
118
124
  await validateRubyEnv();
119
125
  if (usingLocalCLI2) {
120
- await bundleInstallLocalShopifyCLI();
126
+ await bundleInstallLocalShopifyCLI(localCLI);
121
127
  }
122
128
  else {
123
129
  await createShopifyCLIWorkingDirectory();
@@ -174,7 +180,7 @@ async function validateBundler() {
174
180
  * It creates the directory where the Ruby CLI will be downloaded along its dependencies.
175
181
  */
176
182
  async function createShopifyCLIWorkingDirectory() {
177
- return file.mkdir(shopifyCLIDirectory());
183
+ return file.mkdir(await shopifyCLIDirectory());
178
184
  }
179
185
  /**
180
186
  * It creates the directory where the theme-check CLI will be downloaded along its dependencies.
@@ -186,7 +192,7 @@ async function createThemeCheckCLIWorkingDirectory() {
186
192
  * It creates the Gemfile to install The Ruby CLI and the dependencies.
187
193
  */
188
194
  async function createShopifyCLIGemfile() {
189
- const gemPath = joinPath(shopifyCLIDirectory(), 'Gemfile');
195
+ const gemPath = joinPath(await shopifyCLIDirectory(), 'Gemfile');
190
196
  const gemFileContent = ["source 'https://rubygems.org'", `gem 'shopify-cli', '${RubyCLIVersion}'`];
191
197
  const { platform } = platformAndArch();
192
198
  if (platform === 'windows') {
@@ -204,18 +210,21 @@ async function createThemeCheckGemfile() {
204
210
  }
205
211
  /**
206
212
  * It runs bundle install for the dev-managed copy of the Ruby CLI.
213
+ *
214
+ * @param directory - Directory where CLI2 Gemfile is located.
207
215
  */
208
- async function bundleInstallLocalShopifyCLI() {
209
- await exec(bundleExecutable(), ['install'], { cwd: shopifyCLIDirectory() });
216
+ async function bundleInstallLocalShopifyCLI(directory) {
217
+ await exec(bundleExecutable(), ['install'], { cwd: directory });
210
218
  }
211
219
  /**
212
220
  * It runs bundle install for the CLI-managed copy of the Ruby CLI.
213
221
  */
214
222
  async function bundleInstallShopifyCLI() {
215
- await exec(bundleExecutable(), ['config', 'set', '--local', 'path', shopifyCLIDirectory()], {
216
- cwd: shopifyCLIDirectory(),
223
+ const cliDirectory = await shopifyCLIDirectory();
224
+ await exec(bundleExecutable(), ['config', 'set', '--local', 'path', cliDirectory], {
225
+ cwd: cliDirectory,
217
226
  });
218
- await exec(bundleExecutable(), ['install'], { cwd: shopifyCLIDirectory() });
227
+ await exec(bundleExecutable(), ['install'], { cwd: cliDirectory });
219
228
  }
220
229
  /**
221
230
  * It runs bundle install for the CLI-managed copy of theme-check.
@@ -229,11 +238,16 @@ async function bundleInstallThemeCheck() {
229
238
  /**
230
239
  * It returns the directory where the Ruby CLI is located.
231
240
  *
241
+ * @param embedded - True when embebbed codebase of CLI should be used.
232
242
  * @returns The absolute path to the directory.
233
243
  */
234
- function shopifyCLIDirectory() {
235
- return (process.env.SHOPIFY_CLI_2_0_DIRECTORY ??
236
- joinPath(pathConstants.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion));
244
+ async function shopifyCLIDirectory(embedded = false) {
245
+ const embeddedDirectory = (await file.findPathUp('assets/cli-ruby', {
246
+ type: 'directory',
247
+ cwd: dirname(fileURLToPath(import.meta.url)),
248
+ }));
249
+ const bundledDirectory = joinPath(pathConstants.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion);
250
+ return embedded ? embeddedDirectory : process.env.SHOPIFY_CLI_2_0_DIRECTORY ?? bundledDirectory;
237
251
  }
238
252
  /**
239
253
  * It returns the path to the directory containing the theme-check CLI.
@@ -289,4 +303,13 @@ function gemExecutable() {
289
303
  const rubyBinDir = getRubyBinDir();
290
304
  return rubyBinDir ? joinPath(rubyBinDir, 'gem') : 'gem';
291
305
  }
306
+ /**
307
+ * It returns the path to the "bundle" executable.
308
+ *
309
+ * @returns The path to the executable.
310
+ */
311
+ async function embeddedCLIExecutable() {
312
+ const cliDirectory = await shopifyCLIDirectory(true);
313
+ return joinPath(cliDirectory, 'bin', 'shopify');
314
+ }
292
315
  //# sourceMappingURL=ruby.js.map