shopify-cli 0.9.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -3
  3. data/docs/_config.yml +3 -0
  4. data/docs/_data/nav.yml +9 -0
  5. data/docs/getting-started/index.md +5 -40
  6. data/docs/getting-started/install/index.md +75 -0
  7. data/docs/getting-started/migrate/index.md +96 -0
  8. data/docs/getting-started/uninstall/index.md +37 -0
  9. data/docs/getting-started/upgrade/index.md +37 -0
  10. data/docs/index.md +5 -6
  11. data/lib/project_types/extension/cli.rb +3 -2
  12. data/lib/project_types/extension/commands/build.rb +1 -1
  13. data/lib/project_types/extension/commands/tunnel.rb +1 -1
  14. data/lib/project_types/extension/forms/register.rb +2 -3
  15. data/lib/project_types/extension/graphql/get_app_by_api_key.graphql +9 -0
  16. data/lib/project_types/extension/tasks/converters/app_converter.rb +27 -0
  17. data/lib/project_types/extension/tasks/get_app.rb +22 -0
  18. data/lib/project_types/extension/tasks/get_apps.rb +1 -6
  19. data/lib/project_types/node/forms/create.rb +3 -54
  20. data/lib/project_types/node/messages/messages.rb +3 -14
  21. data/lib/project_types/rails/cli.rb +0 -1
  22. data/lib/project_types/rails/forms/create.rb +3 -52
  23. data/lib/project_types/rails/messages/messages.rb +2 -13
  24. data/lib/project_types/script/cli.rb +5 -5
  25. data/lib/project_types/script/commands/create.rb +5 -4
  26. data/lib/project_types/script/commands/disable.rb +4 -14
  27. data/lib/project_types/script/commands/enable.rb +35 -11
  28. data/lib/project_types/script/commands/push.rb +9 -9
  29. data/lib/project_types/script/config/extension_points.yml +9 -3
  30. data/lib/project_types/script/errors.rb +1 -0
  31. data/lib/project_types/script/forms/create.rb +8 -4
  32. data/lib/project_types/script/forms/script_form.rb +5 -2
  33. data/lib/project_types/script/layers/application/create_script.rb +14 -20
  34. data/lib/project_types/script/layers/application/disable_script.rb +9 -7
  35. data/lib/project_types/script/layers/application/enable_script.rb +11 -9
  36. data/lib/project_types/script/layers/application/project_dependencies.rb +0 -5
  37. data/lib/project_types/script/layers/application/push_script.rb +6 -4
  38. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +106 -0
  39. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +2 -2
  40. data/lib/project_types/script/layers/infrastructure/errors.rb +2 -1
  41. data/lib/project_types/script/layers/infrastructure/project_creator.rb +23 -0
  42. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +1 -1
  43. data/lib/project_types/script/layers/infrastructure/script_repository.rb +1 -34
  44. data/lib/project_types/script/layers/infrastructure/script_service.rb +2 -0
  45. data/lib/project_types/script/messages/messages.rb +21 -25
  46. data/lib/project_types/script/script_project.rb +8 -4
  47. data/lib/project_types/script/templates/ts/as-pect.config.js +6 -0
  48. data/lib/project_types/script/templates/ts/as-pect.d.ts +1 -0
  49. data/lib/project_types/script/ui/error_handler.rb +9 -0
  50. data/lib/project_types/script/ui/printing_spinner.rb +75 -0
  51. data/lib/shopify-cli/admin_api.rb +1 -2
  52. data/lib/shopify-cli/admin_api/populate_resource_command.rb +10 -1
  53. data/lib/shopify-cli/admin_api/schema.rb +20 -8
  54. data/lib/shopify-cli/command.rb +2 -5
  55. data/lib/shopify-cli/commands.rb +1 -0
  56. data/lib/shopify-cli/commands/config.rb +44 -0
  57. data/lib/shopify-cli/commands/connect.rb +17 -10
  58. data/lib/shopify-cli/commands/create.rb +1 -1
  59. data/lib/shopify-cli/commands/help.rb +1 -1
  60. data/lib/shopify-cli/commands/system.rb +1 -1
  61. data/lib/shopify-cli/context.rb +10 -1
  62. data/lib/shopify-cli/core.rb +0 -1
  63. data/lib/shopify-cli/core/entry_point.rb +6 -0
  64. data/lib/shopify-cli/core/finalize.rb +13 -0
  65. data/lib/shopify-cli/feature.rb +97 -0
  66. data/lib/shopify-cli/messages/messages.rb +45 -2
  67. data/lib/shopify-cli/partners_api/organizations.rb +7 -7
  68. data/lib/shopify-cli/project_type.rb +2 -5
  69. data/lib/shopify-cli/tasks.rb +1 -0
  70. data/lib/shopify-cli/tasks/ensure_env.rb +0 -1
  71. data/lib/shopify-cli/tasks/select_org_and_shop.rb +77 -0
  72. data/lib/shopify-cli/tasks/update_dashboard_urls.rb +4 -3
  73. data/lib/shopify-cli/tunnel.rb +66 -10
  74. data/lib/shopify-cli/version.rb +1 -1
  75. data/lib/shopify_cli.rb +1 -0
  76. data/vendor/deps/cli-ui/REVISION +1 -1
  77. data/vendor/deps/cli-ui/lib/cli/ui.rb +52 -11
  78. data/vendor/deps/cli-ui/lib/cli/ui/color.rb +11 -7
  79. data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +34 -21
  80. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +107 -149
  81. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +99 -0
  82. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +119 -0
  83. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +158 -0
  84. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +112 -0
  85. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +9 -15
  86. data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +47 -0
  87. data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +9 -7
  88. data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +39 -14
  89. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +62 -44
  90. data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +7 -2
  91. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +23 -3
  92. data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +34 -10
  93. data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +12 -7
  94. data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +26 -16
  95. data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +3 -3
  96. data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +75 -0
  97. data/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +27 -0
  98. data/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +61 -0
  99. metadata +25 -9
  100. data/lib/project_types/extension/features/tunnel_url.rb +0 -20
  101. data/lib/project_types/script/forms/enable.rb +0 -24
  102. data/lib/project_types/script/forms/push.rb +0 -19
  103. data/lib/project_types/script/layers/infrastructure/assemblyscript_dependency_manager.rb +0 -51
  104. data/lib/project_types/script/layers/infrastructure/dependency_manager.rb +0 -36
  105. data/lib/project_types/script/layers/infrastructure/test_suite_repository.rb +0 -62
  106. data/vendor/deps/cli-ui/lib/cli/ui/box.rb +0 -15
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'base64'
3
-
4
- module Extension
5
- module Features
6
- module TunnelUrl
7
- NGROK_TUNNELS_URI = URI.parse('http://localhost:4040/api/tunnels')
8
- TUNNELS_FIELD = 'tunnels'
9
- PUBLIC_URL_FIELD = 'public_url'
10
-
11
- def self.fetch
12
- response = Net::HTTP.get_response(NGROK_TUNNELS_URI)
13
- json = JSON.parse(response.body)
14
- json.dig(TUNNELS_FIELD, 0, PUBLIC_URL_FIELD)
15
- rescue
16
- nil
17
- end
18
- end
19
- end
20
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Forms
5
- class Enable < ScriptForm
6
- flag_arguments :api_key, :shop_domain
7
-
8
- def ask
9
- self.api_key ||= ask_api_key
10
- self.shop_domain ||= ask_shop_domain
11
- end
12
-
13
- private
14
-
15
- def ask_api_key
16
- ask_app_api_key(organization['apps'], message: ctx.message('script.forms.enable.ask_app_api_key'))
17
- end
18
-
19
- def ask_shop_domain
20
- super(organization, message: ctx.message('script.forms.enable.ask_shop_domain'))
21
- end
22
- end
23
- end
24
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Forms
5
- class Push < ScriptForm
6
- flag_arguments :api_key, :force
7
-
8
- def ask
9
- self.api_key ||= ask_api_key
10
- end
11
-
12
- private
13
-
14
- def ask_api_key
15
- ask_app_api_key(organization['apps'])
16
- end
17
- end
18
- end
19
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Layers
5
- module Infrastructure
6
- class AssemblyScriptDependencyManager
7
- def initialize(ctx, language, extension_point, script_name)
8
- @ctx = ctx
9
- @language = language
10
- @script_name = script_name
11
- @extension_point = extension_point
12
- end
13
-
14
- def bootstrap
15
- write_npmrc
16
- write_package_json
17
- end
18
-
19
- private
20
-
21
- def write_npmrc
22
- @ctx.system(
23
- 'npm', '--userconfig', './.npmrc', 'config', 'set', '@shopify:registry', 'https://registry.npmjs.com'
24
- )
25
- end
26
-
27
- def write_package_json
28
- package_json = <<~HERE
29
- {
30
- "name": "#{@script_name}",
31
- "version": "1.0.0",
32
- "devDependencies": {
33
- "@shopify/scripts-sdk-as": "#{@extension_point.sdks[:ts].sdk_version}",
34
- "@shopify/scripts-toolchain-as": "#{@extension_point.sdks[:ts].toolchain_version}",
35
- "#{@extension_point.sdks[:ts].package}": "#{@extension_point.sdks[:ts].version}",
36
- "@as-pect/cli": "4.0.0",
37
- "as-wasi": "^0.0.1",
38
- "assemblyscript": "^0.12.0"
39
- },
40
- "scripts": {
41
- "test": "asp --config test/as-pect.config.js --summary --verbose"
42
- }
43
- }
44
- HERE
45
-
46
- File.write("package.json", package_json)
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Layers
5
- module Infrastructure
6
- class NoopDependencyManager
7
- def initialize(_ctx, language, _extension_point, script_name)
8
- @language = language
9
- @script_name = script_name
10
- end
11
-
12
- def bootstrap
13
- end
14
-
15
- def installed?
16
- end
17
-
18
- def install
19
- end
20
- end
21
-
22
- class DependencyManager
23
- DEP_MANAGER = {
24
- "ts" => AssemblyScriptDependencyManager,
25
- "js" => NoopDependencyManager,
26
- "json" => NoopDependencyManager,
27
- }
28
-
29
- def self.for(ctx, language, extension_point, script_name)
30
- raise Errors::DependencyError, language unless DEP_MANAGER[language]
31
- DEP_MANAGER[language].new(ctx, language, extension_point, script_name)
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'pathname'
4
-
5
- module Script
6
- module Layers
7
- module Infrastructure
8
- class TestSuiteRepository
9
- include SmartProperties
10
- property! :ctx, accepts: ShopifyCli::Context
11
-
12
- ASPECT_DTS_FILENAME = "as-pect.d.ts"
13
- ASPECT_DTS_FILE_CONTENTS = "/// <reference types=\"@as-pect/assembly/types/as-pect\" />"
14
- BOOTSTRAP_TEST = "npx --no-install shopify-scripts-bootstrap test %{test_base}"
15
-
16
- def create_test_suite(script)
17
- # Remove this once we have a test suite for js
18
- return unless script.language == "ts"
19
-
20
- ctx.mkdir_p(test_base)
21
- ctx.cp(aspect_config_template(script.language), "#{test_base}/as-pect.config.js")
22
- out, status = CLI::Kit::System.capture2e(format(BOOTSTRAP_TEST, test_base: test_base))
23
- raise Domain::Errors::ServiceFailureError, out unless status.success?
24
-
25
- write_tsconfig_file
26
- write_aspect_type_definitions_file
27
- end
28
-
29
- private
30
-
31
- def test_dir
32
- "test"
33
- end
34
-
35
- def test_base
36
- "#{ScriptProject.current.directory}/#{test_dir}"
37
- end
38
-
39
- def aspect_config_template(language)
40
- Project.project_filepath("templates/#{language}/as-pect.config.js")
41
- end
42
-
43
- def write_tsconfig_file
44
- AssemblyScriptTsConfig
45
- .new(dir_to_write_in: test_dir)
46
- .with_extends_assemblyscript_config(relative_path_to_node_modules: ".")
47
- .with_module_resolution_paths(paths: { "*": ["#{relative_path_to_source_dir}/*.ts"] })
48
- .write
49
- end
50
-
51
- def relative_path_to_source_dir
52
- src_path_from_root = ScriptRepository.new(ctx: ctx).relative_path_to_src
53
- Pathname.new(src_path_from_root).relative_path_from(test_dir)
54
- end
55
-
56
- def write_aspect_type_definitions_file
57
- File.write("#{test_base}/#{ASPECT_DTS_FILENAME}", ASPECT_DTS_FILE_CONTENTS)
58
- end
59
- end
60
- end
61
- end
62
- end
@@ -1,15 +0,0 @@
1
- require 'cli/ui'
2
-
3
- module CLI
4
- module UI
5
- module Box
6
- module Heavy
7
- VERT = '┃'
8
- HORZ = '━'
9
- DIV = "┣"
10
- TL = '┏'
11
- BL = '┗'
12
- end
13
- end
14
- end
15
- end