shopify-cli 0.9.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +3 -0
  3. data/CHANGELOG.md +26 -0
  4. data/{LICENSE.md → LICENSE} +0 -0
  5. data/RELEASING.md +51 -0
  6. data/Rakefile +1 -6
  7. data/docs/_config.yml +3 -0
  8. data/docs/_data/nav.yml +9 -0
  9. data/docs/getting-started/index.md +5 -40
  10. data/docs/getting-started/install/index.md +39 -0
  11. data/docs/getting-started/migrate/index.md +63 -0
  12. data/docs/getting-started/uninstall/index.md +37 -0
  13. data/docs/getting-started/upgrade/index.md +37 -0
  14. data/docs/index.md +5 -6
  15. data/lib/project_types/extension/cli.rb +2 -1
  16. data/lib/project_types/extension/commands/tunnel.rb +1 -1
  17. data/lib/project_types/extension/forms/register.rb +2 -3
  18. data/lib/project_types/extension/graphql/get_app_by_api_key.graphql +9 -0
  19. data/lib/project_types/extension/tasks/converters/app_converter.rb +27 -0
  20. data/lib/project_types/extension/tasks/get_app.rb +22 -0
  21. data/lib/project_types/extension/tasks/get_apps.rb +1 -6
  22. data/lib/project_types/node/forms/create.rb +3 -54
  23. data/lib/project_types/node/messages/messages.rb +1 -12
  24. data/lib/project_types/rails/forms/create.rb +3 -52
  25. data/lib/project_types/rails/messages/messages.rb +0 -11
  26. data/lib/project_types/script/cli.rb +5 -5
  27. data/lib/project_types/script/commands/create.rb +5 -4
  28. data/lib/project_types/script/commands/push.rb +1 -0
  29. data/lib/project_types/script/errors.rb +1 -0
  30. data/lib/project_types/script/forms/create.rb +8 -4
  31. data/lib/project_types/script/layers/application/build_script.rb +7 -10
  32. data/lib/project_types/script/layers/application/create_script.rb +16 -14
  33. data/lib/project_types/script/layers/application/project_dependencies.rb +3 -9
  34. data/lib/project_types/script/layers/application/push_script.rb +13 -11
  35. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +106 -0
  36. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +64 -0
  37. data/lib/project_types/script/layers/infrastructure/errors.rb +2 -2
  38. data/lib/project_types/script/layers/infrastructure/project_creator.rb +23 -0
  39. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +5 -2
  40. data/lib/project_types/script/layers/infrastructure/script_repository.rb +7 -37
  41. data/lib/project_types/script/layers/infrastructure/task_runner.rb +18 -0
  42. data/lib/project_types/script/messages/messages.rb +5 -6
  43. data/lib/project_types/script/script_project.rb +22 -9
  44. data/lib/project_types/script/templates/ts/as-pect.d.ts +1 -0
  45. data/lib/project_types/script/ui/error_handler.rb +5 -0
  46. data/lib/shopify-cli/admin_api.rb +1 -2
  47. data/lib/shopify-cli/admin_api/populate_resource_command.rb +10 -1
  48. data/lib/shopify-cli/api.rb +2 -0
  49. data/lib/shopify-cli/context.rb +51 -0
  50. data/lib/shopify-cli/core/entry_point.rb +6 -0
  51. data/lib/shopify-cli/core/finalize.rb +13 -0
  52. data/lib/shopify-cli/git.rb +14 -10
  53. data/lib/shopify-cli/messages/messages.rb +22 -2
  54. data/lib/shopify-cli/packager.rb +17 -25
  55. data/lib/shopify-cli/tasks.rb +1 -0
  56. data/lib/shopify-cli/tasks/select_org_and_shop.rb +77 -0
  57. data/lib/shopify-cli/tunnel.rb +33 -1
  58. data/lib/shopify-cli/version.rb +1 -1
  59. data/shopify-cli.gemspec +3 -5
  60. data/vendor/deps/cli-ui/REVISION +1 -1
  61. data/vendor/deps/cli-ui/lib/cli/ui.rb +52 -11
  62. data/vendor/deps/cli-ui/lib/cli/ui/color.rb +11 -7
  63. data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +34 -21
  64. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +107 -149
  65. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +99 -0
  66. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +119 -0
  67. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +158 -0
  68. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +112 -0
  69. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +9 -15
  70. data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +47 -0
  71. data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +9 -7
  72. data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +39 -14
  73. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +62 -44
  74. data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +7 -2
  75. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +23 -3
  76. data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +34 -10
  77. data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +12 -7
  78. data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +26 -16
  79. data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +3 -3
  80. data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +75 -0
  81. data/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +27 -0
  82. data/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +61 -0
  83. metadata +30 -13
  84. data/lib/project_types/extension/features/tunnel_url.rb +0 -20
  85. data/lib/project_types/script/layers/infrastructure/assemblyscript_dependency_manager.rb +0 -73
  86. data/lib/project_types/script/layers/infrastructure/assemblyscript_wasm_builder.rb +0 -39
  87. data/lib/project_types/script/layers/infrastructure/dependency_manager.rb +0 -36
  88. data/lib/project_types/script/layers/infrastructure/script_builder.rb +0 -34
  89. data/lib/project_types/script/layers/infrastructure/test_suite_repository.rb +0 -59
  90. data/vendor/deps/cli-ui/lib/cli/ui/box.rb +0 -15
@@ -16,13 +16,12 @@ module Extension
16
16
  attr_writer :app
17
17
 
18
18
  def ask_app
19
- apps = load_apps
20
-
21
19
  if !api_key.nil?
22
- found_app = apps.find { |app| app.api_key == api_key }
20
+ found_app = Tasks::GetApp.call(context: ctx, api_key: api_key)
23
21
  ctx.abort(ctx.message('register.invalid_api_key', api_key)) if found_app.nil?
24
22
  found_app
25
23
  else
24
+ apps = load_apps
26
25
  CLI::UI::Prompt.ask(ctx.message('register.ask_app')) do |handler|
27
26
  apps.each do |app|
28
27
  handler.option("#{app.title} by #{app.business_name}") { app }
@@ -0,0 +1,9 @@
1
+ query getApp($api_key: String!) {
2
+ app(apiKey: $api_key) {
3
+ title
4
+ apiKey
5
+ apiSecretKeys{
6
+ secret
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+ require 'shopify_cli'
3
+
4
+ module Extension
5
+ module Tasks
6
+ module Converters
7
+ module AppConverter
8
+ API_KEY_FIELD = 'apiKey'
9
+ API_SECRET_KEYS_FIELD = 'apiSecretKeys'
10
+ API_SECRET_FIELD = 'secret'
11
+ TITLE_FIELD = 'title'
12
+ ORGANIZATION_NAME_FIELD = 'businessName'
13
+
14
+ def self.from_hash(hash, organization = {})
15
+ return nil if hash.nil?
16
+
17
+ Models::App.new(
18
+ api_key: hash[API_KEY_FIELD],
19
+ secret: hash[API_SECRET_KEYS_FIELD].first[API_SECRET_FIELD],
20
+ title: hash[TITLE_FIELD],
21
+ business_name: organization[ORGANIZATION_NAME_FIELD]
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ require 'shopify_cli'
3
+
4
+ module Extension
5
+ module Tasks
6
+ class GetApp < ShopifyCli::Task
7
+ GRAPHQL_FILE = 'get_app_by_api_key'
8
+
9
+ RESPONSE_FIELD = %w(data)
10
+ APP_FIELD = 'app'
11
+
12
+ def call(context:, api_key:)
13
+ input = { api_key: api_key }
14
+
15
+ response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, input).dig(*RESPONSE_FIELD)
16
+ context.abort(context.message('tasks.errors.parse_error')) if response.nil?
17
+
18
+ Converters::AppConverter.from_hash(response.dig(APP_FIELD))
19
+ end
20
+ end
21
+ end
22
+ end
@@ -21,12 +21,7 @@ module Extension
21
21
  return [] unless organization.key?('apps') && organization['apps'].any?
22
22
 
23
23
  organization['apps'].map do |app|
24
- Models::App.new(
25
- api_key: app['apiKey'],
26
- secret: app["apiSecretKeys"].first["secret"],
27
- title: app['title'],
28
- business_name: organization['businessName']
29
- )
24
+ Converters::AppConverter.from_hash(app, organization)
30
25
  end
31
26
  end
32
27
  end
@@ -10,8 +10,9 @@ module Node
10
10
  self.title ||= CLI::UI::Prompt.ask(ctx.message('node.forms.create.app_name'))
11
11
  self.type = ask_type
12
12
  self.name = self.title.downcase.split(" ").join("_")
13
- self.organization_id ||= organization["id"].to_i
14
- self.shop_domain ||= ask_shop_domain
13
+ res = ShopifyCli::Tasks::SelectOrgAndShop.call(ctx, organization_id: organization_id, shop_domain: shop_domain)
14
+ self.organization_id = res[:organization_id]
15
+ self.shop_domain = res[:shop_domain]
15
16
  end
16
17
 
17
18
  private
@@ -30,58 +31,6 @@ module Node
30
31
  ctx.puts(ctx.message('node.forms.create.app_type.selected', type))
31
32
  type
32
33
  end
33
-
34
- def organizations
35
- @organizations ||= ShopifyCli::PartnersAPI::Organizations.fetch_all(ctx)
36
- end
37
-
38
- def organization
39
- @organization ||= if !organization_id.nil?
40
- org = ShopifyCli::PartnersAPI::Organizations.fetch(ctx, id: organization_id)
41
- if org.nil?
42
- ctx.puts(ctx.message('node.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
43
- ctx.abort(ctx.message('node.forms.create.error.organization_not_found'))
44
- end
45
- org
46
- elsif organizations.count == 0
47
- ctx.puts(ctx.message('node.forms.create.partners_notice'))
48
- ctx.puts(ctx.message('node.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
49
- ctx.abort(ctx.message('node.forms.create.error.no_organizations'))
50
- elsif organizations.count == 1
51
- org = organizations.first
52
- ctx.puts(ctx.message('node.forms.create.organization',
53
- ctx.message('core.partners_api.org_name_and_id', org['businessName'], org['id'])))
54
- org
55
- else
56
- org_id = CLI::UI::Prompt.ask(ctx.message('node.forms.create.organization_select')) do |handler|
57
- organizations.each do |o|
58
- handler.option(ctx.message('core.partners_api.org_name_and_id', o['businessName'], o['id'])) { o['id'] }
59
- end
60
- end
61
- organizations.find { |o| o['id'] == org_id }
62
- end
63
- end
64
-
65
- def ask_shop_domain
66
- valid_stores = organization['stores'].select do |store|
67
- store['transferDisabled'] == true || store['convertableToPartnerTest'] == true
68
- end
69
-
70
- if valid_stores.count == 0
71
- ctx.puts(ctx.message('node.forms.create.no_development_stores'))
72
- ctx.puts(ctx.message('node.forms.create.create_store', organization['id']))
73
- ctx.puts(ctx.message('node.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
74
- elsif valid_stores.count == 1
75
- domain = valid_stores.first['shopDomain']
76
- ctx.puts(ctx.message('node.forms.create.development_store', domain))
77
- domain
78
- else
79
- CLI::UI::Prompt.ask(
80
- ctx.message('node.forms.create.development_store_select'),
81
- options: valid_stores.map { |s| s['shopDomain'] }
82
- )
83
- end
84
- end
85
34
  end
86
35
  end
87
36
  end
@@ -233,25 +233,14 @@ module Node
233
233
  create: {
234
234
  error: {
235
235
  invalid_app_type: "Invalid app type %s",
236
- organization_not_found: "Cannot find a partner organization with that ID",
237
- no_organizations: "No partner organizations available.",
238
236
  },
239
-
240
- authentication_issue: "For authentication issues, run {{command:%s logout}} to clear invalid credentials",
241
- partners_notice: "Please visit https://partners.shopify.com/ to create a partners account",
242
- no_development_stores: "{{x}} No Development Stores available.",
243
- create_store: "Visit {{underline:https://partners.shopify.com/%s/stores}} to create one",
244
- app_name: "App Name",
237
+ app_name: "App name",
245
238
  app_type: {
246
239
  select: "What type of app are you building?",
247
240
  select_public: "Public: An app built for a wide merchant audience.",
248
241
  select_custom: "Custom: An app custom built for a single client.",
249
242
  selected: "App type {{green:%s}}",
250
243
  },
251
- organization_select: "Select partner organization",
252
- organization: "Partner organization {{green:%s}}",
253
- development_store_select: "Select a development store",
254
- development_store: "Using development store {{green:%s}}",
255
244
  },
256
245
  },
257
246
  },
@@ -22,8 +22,9 @@ module Rails
22
22
  self.title ||= CLI::UI::Prompt.ask(ctx.message('rails.forms.create.app_name'))
23
23
  self.type = ask_type
24
24
  self.name = self.title.downcase.split(" ").join("_")
25
- self.organization_id ||= organization["id"].to_i
26
- self.shop_domain ||= ask_shop_domain
25
+ res = ShopifyCli::Tasks::SelectOrgAndShop.call(ctx, organization_id: organization_id, shop_domain: shop_domain)
26
+ self.organization_id = res[:organization_id]
27
+ self.shop_domain = res[:shop_domain]
27
28
  self.db = ask_db
28
29
  end
29
30
 
@@ -44,56 +45,6 @@ module Rails
44
45
  type
45
46
  end
46
47
 
47
- def organizations
48
- @organizations ||= ShopifyCli::PartnersAPI::Organizations.fetch_all(ctx)
49
- end
50
-
51
- def organization
52
- @organization ||= if !organization_id.nil?
53
- org = ShopifyCli::PartnersAPI::Organizations.fetch(ctx, id: organization_id)
54
- if org.nil?
55
- ctx.puts(ctx.message('rails.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
56
- ctx.abort(ctx.message('rails.forms.create.error.organization_not_found'))
57
- end
58
- org
59
- elsif organizations.count == 0
60
- ctx.puts(ctx.message('rails.forms.create.partners_notice'))
61
- ctx.puts(ctx.message('rails.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
62
- ctx.abort(ctx.message('rails.forms.create.error.no_organizations'))
63
- elsif organizations.count == 1
64
- org = organizations.first
65
- ctx.puts(ctx.message('rails.forms.create.organization',
66
- ctx.message('core.partners_api.org_name_and_id', org['businessName'], org['id'])))
67
- org
68
- else
69
- org_id = CLI::UI::Prompt.ask(ctx.message('rails.forms.create.organization_select')) do |handler|
70
- organizations.each { |o| handler.option(o['businessName']) { o['id'] } }
71
- end
72
- organizations.find { |o| o['id'] == org_id }
73
- end
74
- end
75
-
76
- def ask_shop_domain
77
- valid_stores = organization['stores'].select do |store|
78
- store['transferDisabled'] == true || store['convertableToPartnerTest'] == true
79
- end
80
-
81
- if valid_stores.count == 0
82
- ctx.puts(ctx.message('rails.forms.create.no_development_stores'))
83
- ctx.puts(ctx.message('rails.forms.create.create_store', organization['id']))
84
- ctx.puts(ctx.message('rails.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
85
- elsif valid_stores.count == 1
86
- domain = valid_stores.first['shopDomain']
87
- ctx.puts(ctx.message('rails.forms.create.development_store', domain))
88
- domain
89
- else
90
- CLI::UI::Prompt.ask(
91
- ctx.message('rails.forms.create.development_store_select'),
92
- options: valid_stores.map { |s| s['shopDomain'] }
93
- )
94
- end
95
- end
96
-
97
48
  def ask_db
98
49
  if db.nil?
99
50
  return 'sqlite3' unless CLI::UI::Prompt.confirm(ctx.message('rails.forms.create.db.want_select'),
@@ -236,14 +236,7 @@ module Rails
236
236
  error: {
237
237
  invalid_app_type: "Invalid app type %s",
238
238
  invalid_db_type: "Invalid database type %s",
239
- organization_not_found: "Cannot find a partner organization with that ID",
240
- no_organizations: "No partner organizations available.",
241
239
  },
242
-
243
- authentication_issue: "For authentication issues, run {{command:%s logout}} to clear invalid credentials",
244
- partners_notice: "Please visit https://partners.shopify.com/ to create a partners account",
245
- no_development_stores: "{{x}} No development stores available.",
246
- create_store: "Visit {{underline:https://partners.shopify.com/%s/stores}} to create one",
247
240
  app_name: "App name",
248
241
  app_type: {
249
242
  select: "What type of app are you building?",
@@ -271,10 +264,6 @@ module Rails
271
264
  select_jdbc: "JDBC",
272
265
  selected: "Database Type {{green:%s}}",
273
266
  },
274
- organization_select: "Select partner organization",
275
- organization: "Partner organization {{green:%s}}",
276
- development_store_select: "Select a development store",
277
- development_store: "Using development store {{green:%s}}",
278
267
  },
279
268
  },
280
269
  },
@@ -51,16 +51,16 @@ module Script
51
51
  autoload :Errors, Project.project_filepath('layers/infrastructure/errors')
52
52
  autoload :AssemblyScriptDependencyManager,
53
53
  Project.project_filepath('layers/infrastructure/assemblyscript_dependency_manager')
54
+ autoload :AssemblyScriptProjectCreator,
55
+ Project.project_filepath('layers/infrastructure/assemblyscript_project_creator')
56
+ autoload :AssemblyScriptTaskRunner, Project.project_filepath('layers/infrastructure/assemblyscript_task_runner')
54
57
  autoload :AssemblyScriptTsConfig, Project.project_filepath('layers/infrastructure/assemblyscript_tsconfig')
55
- autoload :AssemblyScriptWasmBuilder,
56
- Project.project_filepath('layers/infrastructure/assemblyscript_wasm_builder')
57
- autoload :DependencyManager, Project.project_filepath('layers/infrastructure/dependency_manager')
58
58
  autoload :PushPackageRepository, Project.project_filepath('layers/infrastructure/push_package_repository')
59
59
  autoload :ExtensionPointRepository, Project.project_filepath('layers/infrastructure/extension_point_repository')
60
- autoload :ScriptBuilder, Project.project_filepath('layers/infrastructure/script_builder')
60
+ autoload :ProjectCreator, Project.project_filepath('layers/infrastructure/project_creator')
61
61
  autoload :ScriptRepository, Project.project_filepath('layers/infrastructure/script_repository')
62
62
  autoload :ScriptService, Project.project_filepath('layers/infrastructure/script_service')
63
- autoload :TestSuiteRepository, Project.project_filepath('layers/infrastructure/test_suite_repository')
63
+ autoload :TaskRunner, Project.project_filepath('layers/infrastructure/task_runner')
64
64
  end
65
65
  end
66
66
 
@@ -19,16 +19,17 @@ module Script
19
19
  return @ctx.puts(self.class.help)
20
20
  end
21
21
 
22
- script = Layers::Application::CreateScript.call(
22
+ Layers::Application::CreateScript.call(
23
23
  ctx: @ctx,
24
24
  language: language,
25
25
  script_name: form.name,
26
26
  extension_point_type: form.extension_point
27
27
  )
28
- @ctx.puts(@ctx.message('script.create.script_path', folder: script.name))
29
- @ctx.puts(@ctx.message('script.create.script_created', script_id: File.join(script.name, script.id)))
28
+ project = ScriptProject.current
29
+ @ctx.puts(@ctx.message('script.create.script_path', folder: project.script_name))
30
+ @ctx.puts(@ctx.message('script.create.script_created', script_id: project.source_file))
30
31
  rescue StandardError => e
31
- ScriptProject.cleanup(ctx: @ctx, script_name: form.name, root_dir: cur_dir)
32
+ ScriptProject.cleanup(ctx: @ctx, script_name: form.name, root_dir: cur_dir) if form
32
33
  UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.create.error.operation_failed'))
33
34
  end
34
35
 
@@ -19,6 +19,7 @@ module Script
19
19
  language: project.language,
20
20
  extension_point_type: project.extension_point_type,
21
21
  script_name: project.script_name,
22
+ source_file: project.source_file,
22
23
  api_key: form.api_key,
23
24
  force: form.force
24
25
  )
@@ -3,6 +3,7 @@
3
3
  module Script
4
4
  module Errors
5
5
  class InvalidContextError < ScriptProjectError; end
6
+ class InvalidScriptNameError < ScriptProjectError; end
6
7
  class NoExistingAppsError < ScriptProjectError; end
7
8
  class NoExistingOrganizationsError < ScriptProjectError; end
8
9
  class NoExistingStoresError < ScriptProjectError
@@ -6,7 +6,7 @@ module Script
6
6
  flag_arguments :extension_point, :name
7
7
 
8
8
  def ask
9
- self.name = (name || ask_name).downcase.gsub(' ', '_')
9
+ self.name = valid_name
10
10
  self.extension_point ||= ask_extension_point
11
11
  end
12
12
 
@@ -20,9 +20,13 @@ module Script
20
20
  end
21
21
 
22
22
  def ask_name
23
- name = CLI::UI::Prompt.ask(@ctx.message('script.forms.create.script_name'))
24
- return name if name.match?(/^[0-9A-Za-z _-]*$/)
25
- @ctx.abort(@ctx.message('script.forms.create.error.invalid_name'))
23
+ CLI::UI::Prompt.ask(@ctx.message('script.forms.create.script_name'))
24
+ end
25
+
26
+ def valid_name
27
+ n = (name || ask_name).downcase.gsub(' ', '_')
28
+ return n if n.match?(/^[0-9A-Za-z_-]*$/)
29
+ raise Errors::InvalidScriptNameError
26
30
  end
27
31
  end
28
32
  end
@@ -5,11 +5,11 @@ module Script
5
5
  module Application
6
6
  class BuildScript
7
7
  class << self
8
- def call(ctx:, script:)
8
+ def call(ctx:, task_runner:, script:)
9
9
  return if CLI::UI::Frame.open(ctx.message('script.application.building')) do
10
10
  begin
11
11
  UI::StrictSpinner.spin(ctx.message('script.application.building_script')) do |spinner|
12
- build(script)
12
+ build(ctx, task_runner, script)
13
13
  spinner.update_title(ctx.message('script.application.built'))
14
14
  end
15
15
  true
@@ -25,16 +25,13 @@ module Script
25
25
 
26
26
  private
27
27
 
28
- def build(script)
29
- script_repo = Infrastructure::ScriptRepository.new
30
- script_builder = Infrastructure::ScriptBuilder.for(script)
31
- compiled_type = script_builder.compiled_type
28
+ def build(ctx, task_runner, script)
29
+ script_repo = Infrastructure::ScriptRepository.new(ctx: ctx)
32
30
  script_content = script_repo.with_temp_build_context do
33
- script_builder.build
31
+ task_runner.build
34
32
  end
35
-
36
- Infrastructure::PushPackageRepository.new
37
- .create_push_package(script, script_content, compiled_type)
33
+ Infrastructure::PushPackageRepository.new(ctx: ctx)
34
+ .create_push_package(script, script_content, task_runner.compiled_type)
38
35
  end
39
36
  end
40
37
  end
@@ -9,15 +9,17 @@ module Script
9
9
  class << self
10
10
  def call(ctx:, language:, script_name:, extension_point_type:)
11
11
  extension_point = ExtensionPoints.get(type: extension_point_type)
12
- create_project(ctx, language, script_name, extension_point)
13
- create_definition(ctx, language, extension_point, script_name)
12
+ project = setup_project(ctx, script_name, extension_point)
13
+ project_creator = Infrastructure::ProjectCreator
14
+ .for(ctx, language, extension_point, script_name, project.directory)
15
+ install_dependencies(ctx, language, script_name, project, project_creator)
16
+ bootstrap(ctx, project_creator)
14
17
  end
15
18
 
16
19
  private
17
20
 
18
- def create_project(ctx, language, script_name, extension_point)
19
- ScriptProject.create(script_name)
20
- ctx.root = File.join(ctx.root, script_name)
21
+ def setup_project(ctx, script_name, extension_point)
22
+ ScriptProject.create(ctx, script_name)
21
23
  ScriptProject.write(
22
24
  ctx,
23
25
  project_type: :script,
@@ -25,20 +27,20 @@ module Script
25
27
  extension_point_type: extension_point.type,
26
28
  script_name: script_name
27
29
  )
28
- ProjectDependencies
29
- .bootstrap(ctx: ctx, language: language, extension_point: extension_point, script_name: script_name)
30
- ProjectDependencies
31
- .install(ctx: ctx, language: language, extension_point: extension_point, script_name: script_name)
30
+ ScriptProject.current
32
31
  end
33
32
 
34
- def create_definition(ctx, language, extension_point, script_name)
35
- script = nil
33
+ def install_dependencies(ctx, language, script_name, project, project_creator)
34
+ task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name, project.source_file)
35
+ project_creator.setup_dependencies
36
+ ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
37
+ end
38
+
39
+ def bootstrap(ctx, project_creator)
36
40
  UI::StrictSpinner.spin(ctx.message('script.create.creating')) do |spinner|
37
- script = Infrastructure::ScriptRepository.new.create_script(language, extension_point, script_name)
38
- Infrastructure::TestSuiteRepository.new.create_test_suite(script)
41
+ project_creator.bootstrap
39
42
  spinner.update_title(ctx.message('script.create.created'))
40
43
  end
41
- script
42
44
  end
43
45
  end
44
46
  end