shopify-cli 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/workflows/shopify.yml +106 -0
  4. data/.gitignore +2 -0
  5. data/CHANGELOG.md +6 -0
  6. data/CONTRIBUTING.md +23 -0
  7. data/Dockerfile +19 -0
  8. data/Gemfile +1 -0
  9. data/Gemfile.lock +50 -13
  10. data/Rakefile +66 -0
  11. data/dev.yml +11 -1
  12. data/ext/shopify-extensions/extconf.rb +21 -0
  13. data/ext/shopify-extensions/shopify_extensions.rb +152 -0
  14. data/ext/shopify-extensions/version +1 -0
  15. data/lib/project_types/extension/cli.rb +14 -0
  16. data/lib/project_types/extension/commands/build.rb +30 -2
  17. data/lib/project_types/extension/commands/create.rb +25 -0
  18. data/lib/project_types/extension/forms/create.rb +4 -1
  19. data/lib/project_types/extension/forms/questions/ask_template.rb +44 -0
  20. data/lib/project_types/extension/messages/messages.rb +3 -0
  21. data/lib/project_types/extension/models/development_server.rb +35 -0
  22. data/lib/project_types/extension/models/development_server_requirements.rb +17 -0
  23. data/lib/project_types/extension/models/server_config/base.rb +31 -0
  24. data/lib/project_types/extension/models/server_config/development.rb +23 -0
  25. data/lib/project_types/extension/models/server_config/development_entries.rb +38 -0
  26. data/lib/project_types/extension/models/server_config/development_renderer.rb +30 -0
  27. data/lib/project_types/extension/models/server_config/extension.rb +35 -0
  28. data/lib/project_types/extension/models/server_config/root.rb +18 -0
  29. data/lib/project_types/extension/models/server_config/user.rb +10 -0
  30. data/lib/project_types/extension/tasks/choose_next_available_port.rb +1 -1
  31. data/lib/project_types/extension/tasks/run_extension_command.rb +58 -0
  32. data/lib/project_types/node/commands/create.rb +1 -5
  33. data/lib/project_types/rails/commands/create.rb +1 -5
  34. data/lib/project_types/script/cli.rb +2 -0
  35. data/lib/project_types/script/layers/application/push_script.rb +10 -1
  36. data/lib/project_types/script/layers/domain/push_package.rb +0 -12
  37. data/lib/project_types/script/layers/infrastructure/api_clients.rb +89 -0
  38. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +1 -1
  39. data/lib/project_types/script/layers/infrastructure/script_service.rb +26 -141
  40. data/lib/project_types/script/layers/infrastructure/script_uploader.rb +27 -0
  41. data/lib/project_types/script/tasks/ensure_env.rb +2 -2
  42. data/lib/project_types/script/ui/error_handler.rb +1 -1
  43. data/lib/shopify-cli/constants.rb +26 -0
  44. data/lib/shopify-cli/environment.rb +60 -0
  45. data/lib/shopify-cli/git.rb +2 -2
  46. data/lib/shopify-cli/identity_auth.rb +16 -23
  47. data/lib/shopify-cli/partners_api.rb +3 -27
  48. data/lib/shopify-cli/theme/dev_server/hot_reload.rb +4 -5
  49. data/lib/shopify-cli/theme/development_theme.rb +16 -2
  50. data/lib/shopify-cli/version.rb +1 -1
  51. data/lib/shopify_cli.rb +4 -2
  52. data/shopify-cli.gemspec +3 -3
  53. metadata +29 -9
  54. data/.github/workflows/build.yml +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 200674ac9337744994af930500ea30904f13292fba380ec0d58cf990f94c50f5
4
- data.tar.gz: cb7f7b17ebbdbc430afe269d713e68cf9db00e71a7aa5026c1752ba8f2db9792
3
+ metadata.gz: d5e31b928a8c3d1e98c383786f85be502045be59731cef6adcd2fde4f337c4d7
4
+ data.tar.gz: c0f5fc0e586f2fef7a7e2a92d9357acf06547b53545bc1319e6bcf58f636fb1b
5
5
  SHA512:
6
- metadata.gz: eed6884b0ee2ec5dc30bfbd4927dedb13ac3a77088af02a24ada09b08d1341696c56c8ce01d177cffe7c67f5db262d2146c51a0f95345e628c1e8a477debe543
7
- data.tar.gz: e5211bf92e8b8cab56a17e3714ffcc3d8a8bf8d63aa408c4621a1a65778d4ff0a0d3ae6c57613ee46661d19d9441246aa57388f58f46116acbb712c8f1841750
6
+ metadata.gz: 9699459d8bf5a49683a00b8b166a7dc5b09be204b5d0bc0d73288508dc08eace03ddba62223f20001183931895434102f8d5cfd66f3494afc1f2fa5d1a4700c5
7
+ data.tar.gz: e980565315b842028e05786f1acf63fae983d00ff28aa2db71d976d3b3b3615a530c47710727fe83c311a6bca8cec0995fc34cb5a288a7ff2d223510ddd0c79f
data/.github/CODEOWNERS CHANGED
@@ -1,4 +1,5 @@
1
1
  * @shopify/core-build-learn
2
+ * @shopify/development-lifecycle
2
3
 
3
4
  /lib/project_types/script/ @shopify/scripts-experience
4
5
  /test/project_types/script/ @shopify/scripts-experience
@@ -0,0 +1,106 @@
1
+ name: Shopify
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ concurrency:
10
+ group: shopify-${{ github.head_ref }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ test:
15
+ name: Tests with Ruby ${{ matrix.version }} on ${{ matrix.os }}
16
+ runs-on: ${{ matrix.os }}
17
+ strategy:
18
+ matrix:
19
+ version:
20
+ - 3.0.2
21
+ - 2.6.6
22
+ - 2.7.1
23
+ os:
24
+ - macos-10.15
25
+ - macos-11
26
+ - ubuntu-20.04
27
+ - ubuntu-18.04
28
+ - ubuntu-16.04
29
+ steps:
30
+ - uses: actions/checkout@v2
31
+ - name: Set Git configuration
32
+ run: |
33
+ git config --global user.email "development-lifecycle@shopify.com"
34
+ git config --global user.name "Development Lifecycle"
35
+
36
+ - name: Set up Ruby ${{ matrix.version }}
37
+ uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: ${{ matrix.version }}
40
+ bundler-cache: true
41
+
42
+ - name: Install Dependencies
43
+ run: bundle install
44
+
45
+ - name: Run Tests
46
+ run: bundle exec rake test
47
+ acceptance_tests:
48
+ name: Acceptance Tests with Ruby ${{ matrix.version }} on ${{ matrix.os }}
49
+ runs-on: ${{ matrix.os }}
50
+ strategy:
51
+ matrix:
52
+ version:
53
+ - 3.0.2
54
+ - 2.6.6
55
+ - 2.7.1
56
+ os:
57
+ - macos-10.15
58
+ - macos-11
59
+ - ubuntu-20.04
60
+ - ubuntu-18.04
61
+ - ubuntu-16.04
62
+ steps:
63
+ - uses: actions/checkout@v2
64
+ - name: Set Git configuration
65
+ run: |
66
+ git config --global user.email "development-lifecycle@shopify.com"
67
+ git config --global user.name "Development Lifecycle"
68
+
69
+ - name: Set up Ruby ${{ matrix.version }}
70
+ uses: ruby/setup-ruby@v1
71
+ with:
72
+ ruby-version: ${{ matrix.version }}
73
+ bundler-cache: true
74
+
75
+ - uses: actions/setup-node@v2
76
+ with:
77
+ node-version: "14.9.0"
78
+
79
+ - name: Install Dependencies
80
+ run: bundle install
81
+
82
+ - name: Run Tests
83
+ run: bundle exec cucumber
84
+ rubocop:
85
+ name: Rubocop
86
+ runs-on: ${{ matrix.os }}
87
+ strategy:
88
+ matrix:
89
+ version:
90
+ - 3.0.2
91
+ os:
92
+ - macos-latest
93
+ steps:
94
+ - uses: actions/checkout@v2
95
+
96
+ - name: Set up Ruby ${{ matrix.version }}
97
+ uses: ruby/setup-ruby@v1
98
+ with:
99
+ ruby-version: ${{ matrix.version }}
100
+ bundler-cache: true
101
+
102
+ - name: Install Dependencies
103
+ run: bundle install
104
+
105
+ - name: Rubocop
106
+ run: bundle exec rake rubocop
data/.gitignore CHANGED
@@ -19,3 +19,5 @@ packaging/debian/shopify-cli
19
19
  packaging/debian/shopify-cli.deb
20
20
  packaging/rpm/build
21
21
  packaging/rpm/shopify-cli.spec
22
+ .byebug_history
23
+ ext/shopify-extensions/shopify-extensions
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  Unreleased
2
2
  ------
3
3
 
4
+ Version 2.4.0
5
+ ------
6
+
7
+ * [#1488](https://github.com/Shopify/shopify-cli/pull/1488): Update Theme-Check to 1.4
8
+ * [#1507](https://github.com/Shopify/shopify-cli/pull/1507): Limit the generated name for themes to 50 characters
9
+
4
10
  Version 2.3.0
5
11
  ------
6
12
 
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,23 @@
1
+ # Contributing
2
+
3
+ This documents includes guidelines for contributors.
4
+
5
+ ## Testing
6
+
7
+ The project employs a diverse suite tests that help ensure it works as intended and prevents regressions as it continues to grow and evolve.
8
+
9
+ ### Unit Tests
10
+ Most of the internal components the project uses have unit tests to thoroughly test them. Here dependencies of components are mocked or stubbed appropriately to ensure tests are reliable, test only one component and are fast!
11
+
12
+ ### Acceptance Tests
13
+
14
+ Acceptance tests run the built `shopify` command line against a wide range of fixtures and verify its output and results. They are the slowest to run however provide the most coverage. The idea is to test a few complete scenarios for each major feature.
15
+
16
+ Those are written in [Cucumber](https://cucumber.io/) and Ruby and can be found in the [`features/`](/features) directory. They can be executed by running
17
+
18
+ ```bash
19
+ bundle exec cucumber
20
+ bundle exec cucumber features/theme.feature:3 # A specific test
21
+ ```
22
+
23
+ > **Note** that we currently don't have an approach for stubbing the interactions with the GraphQL APIs and that therefore we can't write acceptance tests for commands that interact with APIs.
data/Dockerfile ADDED
@@ -0,0 +1,19 @@
1
+ # This is a Docker image to test the CLI in UNIX environments other than macOS
2
+ # Build the image: docker build . -t shopify-cli
3
+ # Run tests: docker run -t --rm --volume "$(pwd):/usr/src/app" shopify-cli bundle exec rake test
4
+ FROM cimg/ruby:2.7.1-node
5
+
6
+ RUN git config --global user.email "development-lifecycle@shopify.com"
7
+ RUN git config --global user.name "Development Lifecycle"
8
+
9
+ # throw errors if Gemfile has been modified since Gemfile.lock
10
+ RUN bundle config --global frozen 1
11
+
12
+ WORKDIR /usr/src/app
13
+
14
+ COPY Gemfile Gemfile.lock ./
15
+ COPY shopify-cli.gemspec shopify-cli.gemspec
16
+ COPY lib/shopify-cli/version.rb lib/shopify-cli/version.rb
17
+ COPY . .
18
+
19
+ RUN bundle install
data/Gemfile CHANGED
@@ -24,4 +24,5 @@ group :test do
24
24
  gem "webmock", require: false
25
25
  gem "timecop", require: false
26
26
  gem "rack", require: false
27
+ gem "cucumber", "~> 7.0", require: false
27
28
  end
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.3.0)
5
- listen (~> 3.5)
6
- theme-check (~> 1.2)
4
+ shopify-cli (2.4.0)
5
+ listen (~> 3.7.0)
6
+ theme-check (~> 1.4.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.7.0)
11
+ addressable (2.8.0)
12
12
  public_suffix (>= 2.0.2, < 5.0)
13
13
  ansi (1.5.0)
14
14
  ast (2.4.2)
@@ -16,15 +16,50 @@ GEM
16
16
  byebug (11.1.3)
17
17
  coderay (1.1.3)
18
18
  crack (0.4.4)
19
+ cucumber (7.0.0)
20
+ builder (~> 3.2, >= 3.2.4)
21
+ cucumber-core (~> 10.0, >= 10.0.1)
22
+ cucumber-create-meta (~> 6.0, >= 6.0.1)
23
+ cucumber-cucumber-expressions (~> 12.1, >= 12.1.1)
24
+ cucumber-gherkin (~> 20.0, >= 20.0.1)
25
+ cucumber-html-formatter (~> 16.0, >= 16.0.1)
26
+ cucumber-messages (~> 17.0, >= 17.0.1)
27
+ cucumber-wire (~> 6.0, >= 6.0.1)
28
+ diff-lcs (~> 1.4, >= 1.4.4)
29
+ mime-types (~> 3.3, >= 3.3.1)
30
+ multi_test (~> 0.1, >= 0.1.2)
31
+ sys-uname (~> 1.2, >= 1.2.2)
32
+ cucumber-core (10.0.1)
33
+ cucumber-gherkin (~> 20.0, >= 20.0.1)
34
+ cucumber-messages (~> 17.0, >= 17.0.1)
35
+ cucumber-tag-expressions (~> 3.0, >= 3.0.1)
36
+ cucumber-create-meta (6.0.1)
37
+ cucumber-messages (~> 17.0, >= 17.0.1)
38
+ sys-uname (~> 1.2, >= 1.2.2)
39
+ cucumber-cucumber-expressions (12.1.3)
40
+ cucumber-gherkin (20.0.1)
41
+ cucumber-messages (~> 17.0, >= 17.0.1)
42
+ cucumber-html-formatter (16.0.1)
43
+ cucumber-messages (~> 17.0, >= 17.0.1)
44
+ cucumber-messages (17.1.0)
45
+ cucumber-tag-expressions (3.0.1)
46
+ cucumber-wire (6.1.1)
47
+ cucumber-core (~> 10.0, >= 10.0.1)
48
+ cucumber-cucumber-expressions (~> 12.1, >= 12.1.2)
49
+ cucumber-messages (~> 17.0, >= 17.0.1)
50
+ diff-lcs (1.4.4)
19
51
  fakefs (1.2.2)
20
52
  ffi (1.15.3)
21
53
  hashdiff (1.0.1)
22
54
  liquid (5.0.1)
23
- listen (3.5.1)
55
+ listen (3.7.0)
24
56
  rb-fsevent (~> 0.10, >= 0.10.3)
25
57
  rb-inotify (~> 0.9, >= 0.9.10)
26
58
  method_source (1.0.0)
27
- mini_portile2 (2.5.3)
59
+ mime-types (3.3.1)
60
+ mime-types-data (~> 3.2015)
61
+ mime-types-data (3.2021.0901)
62
+ mini_portile2 (2.6.1)
28
63
  minitest (5.14.2)
29
64
  minitest-fail-fast (0.1.0)
30
65
  minitest (~> 5)
@@ -34,11 +69,10 @@ GEM
34
69
  minitest (>= 5.0)
35
70
  ruby-progressbar
36
71
  mocha (1.11.2)
37
- nokogiri (1.11.7)
38
- mini_portile2 (~> 2.5.0)
72
+ multi_test (0.1.2)
73
+ nokogiri (1.12.4)
74
+ mini_portile2 (~> 2.6.1)
39
75
  racc (~> 1.4)
40
- nokogumbo (2.0.5)
41
- nokogiri (~> 1.8, >= 1.8.4)
42
76
  parallel (1.20.1)
43
77
  parser (3.0.1.0)
44
78
  ast (~> 2.4.1)
@@ -76,9 +110,11 @@ GEM
76
110
  rubocop-shopify (2.0.1)
77
111
  rubocop (~> 1.11)
78
112
  ruby-progressbar (1.11.0)
79
- theme-check (1.2.0)
113
+ sys-uname (1.2.2)
114
+ ffi (~> 1.1)
115
+ theme-check (1.4.0)
80
116
  liquid (>= 5.0.1)
81
- nokogumbo
117
+ nokogiri (>= 1.12)
82
118
  timecop (0.9.2)
83
119
  unicode-display_width (2.0.0)
84
120
  webmock (3.9.3)
@@ -90,8 +126,9 @@ PLATFORMS
90
126
  ruby
91
127
 
92
128
  DEPENDENCIES
93
- bundler (~> 2.1.4)
129
+ bundler (~> 2.2.2)
94
130
  byebug
131
+ cucumber (~> 7.0)
95
132
  fakefs (>= 1.0)
96
133
  minitest (>= 5.0.0)
97
134
  minitest-fail-fast
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ require_relative "bin/load_shopify"
2
2
  require "rake/testtask"
3
3
  require "rubocop/rake_task"
4
4
  require "bundler/gem_tasks"
5
+ require "shellwords"
5
6
 
6
7
  Rake::TestTask.new do |t|
7
8
  t.libs += %w(test)
@@ -10,6 +11,33 @@ Rake::TestTask.new do |t|
10
11
  t.warning = false
11
12
  end
12
13
 
14
+ desc "A set of tasks that run in Linux environments"
15
+ namespace :linux do
16
+ desc "Runs the test suite in a Linux Docker environment"
17
+ task :test do
18
+ system("docker", "build", __dir__, "-t", "shopify-cli") || abort
19
+ system(
20
+ "docker", "run",
21
+ "-t", "--rm",
22
+ "--volume", "#{Shellwords.escape(__dir__)}:/usr/src/app",
23
+ "shopify-cli",
24
+ "bundle", "exec", "rake", "test"
25
+ ) || abort
26
+ end
27
+
28
+ desc "Runs the acceptance tests suite in a Linux Docker environment"
29
+ task :features do
30
+ system("docker", "build", __dir__, "-t", "shopify-cli") || abort
31
+ system(
32
+ "docker", "run",
33
+ "-t", "--rm",
34
+ "--volume", "#{Shellwords.escape(__dir__)}:/usr/src/app",
35
+ "shopify-cli",
36
+ "bundle", "exec", "cucumber"
37
+ ) || abort
38
+ end
39
+ end
40
+
13
41
  RuboCop::RakeTask.new
14
42
 
15
43
  task(default: [:test, :rubocop])
@@ -98,3 +126,41 @@ end
98
126
 
99
127
  desc("Builds all distribution packages of the CLI")
100
128
  task(package: "package:all")
129
+
130
+ namespace :extensions do
131
+ task :update do
132
+ version = ENV.fetch("VERSION").strip
133
+ error("Invalid version") unless /^v\d+\.\d+\.\d+/.match(version)
134
+ File.write(Paths.extension("version"), version)
135
+ end
136
+
137
+ task :symlink do
138
+ source = Paths.root("..", "shopify-cli-extensions", "shopify-extensions")
139
+ error("Unable to find shopify-extensions executable: #{executable}") unless File.executable?(source)
140
+ target = Paths.extension("shopify-extensions")
141
+ File.delete(target) if File.exist?(target)
142
+ File.symlink(source, target)
143
+ end
144
+
145
+ task :install do
146
+ target = Paths.extension("shopify-extensions")
147
+ require_relative Paths.extension("shopify_extensions.rb")
148
+ File.delete(target) if File.exist?(target)
149
+ ShopifyExtensions.install(target: target)
150
+ end
151
+
152
+ module Paths
153
+ def self.extension(*args)
154
+ root("ext", "shopify-extensions", *args)
155
+ end
156
+
157
+ def self.root(*args)
158
+ Pathname(File.dirname(__FILE__)).join(*args).to_s
159
+ end
160
+ end
161
+ end
162
+
163
+ def error(message, output: STDERR, code: 1)
164
+ output.puts(message)
165
+ exit(code)
166
+ end
data/dev.yml CHANGED
@@ -4,13 +4,19 @@ type:
4
4
 
5
5
  up:
6
6
  - ruby: 2.7.1
7
+ - homebrew:
8
+ - dpkg:
9
+ version: 1.20.9
10
+ - rpm:
11
+ version: 4.16.1.3
7
12
  - bundler
8
13
  - node:
9
14
  version: 14.9.0
10
15
  yarn: true
16
+ - docker
11
17
 
12
18
  test:
13
- desc: 'Run tests.'
19
+ desc: "Run tests."
14
20
  run: |
15
21
  if [ "$#" -eq 1 ] && [[ -f $1 ]];
16
22
  then
@@ -18,3 +24,7 @@ test:
18
24
  else
19
25
  bundle exec rake test $@
20
26
  fi
27
+
28
+ commands:
29
+ style:
30
+ run: bundle exec rubocop .
@@ -0,0 +1,21 @@
1
+ require_relative "./shopify_extensions"
2
+
3
+ installation_dir = ENV.fetch("SHOPIFY_CLI_EXTENSIONS_INSTALLATION_DIR", __dir__)
4
+
5
+ File.write(File.expand_path("Makefile", installation_dir), <<~MAKEFILE)
6
+ .PHONY: clean
7
+
8
+ clean: ;
9
+
10
+ install: ;
11
+ MAKEFILE
12
+
13
+ begin
14
+ ShopifyExtensions.install(
15
+ target: File.expand_path("shopify-extensions", installation_dir)
16
+ )
17
+ rescue ShopifyExtensions::InstallationError => error
18
+ STDERR.puts(error.message)
19
+ rescue => error
20
+ STDERR.puts("Unable to install shopify-extensions: #{error}")
21
+ end
@@ -0,0 +1,152 @@
1
+ require "rbconfig"
2
+ require "open-uri"
3
+ require "zlib"
4
+ require "open3"
5
+
6
+ module ShopifyExtensions
7
+ def self.install(**args)
8
+ Install.call(**args)
9
+ end
10
+
11
+ class Install
12
+ def self.call(platform: Platform.new, **args)
13
+ new.call(platform: platform, **args)
14
+ end
15
+
16
+ def self.version
17
+ File.read(File.expand_path("../version", __FILE__)).strip
18
+ end
19
+
20
+ def call(platform:, version: self.class.version, target:)
21
+ target = platform.format_path(target.to_s)
22
+
23
+ asset = Asset.new(
24
+ platform: platform,
25
+ version: version,
26
+ owner: "Shopify",
27
+ repository: "shopify-cli-extensions",
28
+ basename: "shopify-extensions"
29
+ )
30
+ downloaded = asset.download(target: target)
31
+ raise InstallationError.asset_not_found(platform: platform, version: version) unless downloaded
32
+
33
+ raise InstallationError.installation_failed unless verify(target, version: version)
34
+ end
35
+
36
+ private
37
+
38
+ def fetch_release_details_for(version:)
39
+ JSON.parse(URI.parse(release_url_for(version: version)).open.read).yield_self(&Release)
40
+ rescue OpenURI::HTTPError
41
+ nil
42
+ end
43
+
44
+ def verify(target, version:)
45
+ return false unless File.executable?(target)
46
+ installed_server_version, exit_code = Open3.capture2(target, "version")
47
+ return false unless exit_code == 0
48
+ return false unless installed_server_version.strip == version.strip
49
+ true
50
+ end
51
+ end
52
+
53
+ class InstallationError < RuntimeError
54
+ def self.installation_failed
55
+ new("Failed to install shopify-extensions properly")
56
+ end
57
+
58
+ def self.asset_not_found(platform:, version:)
59
+ new(format(
60
+ "Unable to download shopify-extensions %{version} for %{os} (%{cpu})",
61
+ version: version,
62
+ os: platform.os,
63
+ cpu: platform.cpu
64
+ ))
65
+ end
66
+ end
67
+
68
+ Asset = Struct.new(:platform, :version, :owner, :repository, :basename, keyword_init: true) do
69
+ def download(target:)
70
+ Dir.chdir(File.dirname(target)) do
71
+ File.open(File.basename(target), "wb") do |target_file|
72
+ decompress(url.open, target_file)
73
+ end
74
+ File.chmod(0755, target)
75
+ end
76
+
77
+ true
78
+ rescue OpenURI::HTTPError
79
+ false
80
+ end
81
+
82
+ def url
83
+ URI.parse(format(
84
+ "https://github.com/%{owner}/%{repository}/releases/download/%{version}/%{filename}",
85
+ owner: owner,
86
+ repository: repository,
87
+ version: version,
88
+ filename: filename
89
+ ))
90
+ end
91
+
92
+ def filename
93
+ format(
94
+ "%{basename}-%{os}-%{cpu}.%{extension}",
95
+ basename: basename,
96
+ os: platform.os,
97
+ cpu: platform.cpu,
98
+ extension: platform.os == "windows" ? "exe.gz" : "gz"
99
+ )
100
+ end
101
+
102
+ private
103
+
104
+ def decompress(source, target)
105
+ zlib = Zlib::GzipReader.new(source)
106
+ target << zlib.read
107
+ ensure
108
+ zlib.close
109
+ end
110
+ end
111
+
112
+ Platform = Struct.new(:ruby_config) do
113
+ def initialize(ruby_config = RbConfig::CONFIG)
114
+ super(ruby_config)
115
+ end
116
+
117
+ def format_path(path)
118
+ case os
119
+ when "windows"
120
+ File.extname(path) != ".exe" ? path + ".exe" : path
121
+ else
122
+ path
123
+ end
124
+ end
125
+
126
+ def to_s
127
+ format("%{os}-%{cpu}", os: os, cpu: cpu)
128
+ end
129
+
130
+ def os
131
+ case ruby_config.fetch("host_os")
132
+ when /linux/
133
+ "linux"
134
+ when /darwin/
135
+ "darwin"
136
+ else
137
+ "windows"
138
+ end
139
+ end
140
+
141
+ def cpu
142
+ case ruby_config.fetch("host_cpu")
143
+ when /arm.*64/
144
+ "arm64"
145
+ when /64/
146
+ "amd64"
147
+ else
148
+ "386"
149
+ end
150
+ end
151
+ end
152
+ end
@@ -0,0 +1 @@
1
+ v0.1.0
@@ -41,6 +41,7 @@ module Extension
41
41
  autoload :FindNpmPackages, Project.project_filepath("tasks/find_npm_packages")
42
42
  autoload :GetExtensions, Project.project_filepath("tasks/get_extensions")
43
43
  autoload :GetProduct, Project.project_filepath("tasks/get_product")
44
+ autoload :RunExtensionCommand, Project.project_filepath("tasks/run_extension_command")
44
45
 
45
46
  module Converters
46
47
  autoload :RegistrationConverter, Project.project_filepath("tasks/converters/registration_converter")
@@ -55,6 +56,7 @@ module Extension
55
56
  module Questions
56
57
  autoload :AskApp, Project.project_filepath("forms/questions/ask_app")
57
58
  autoload :AskName, Project.project_filepath("forms/questions/ask_name")
59
+ autoload :AskTemplate, Project.project_filepath("forms/questions/ask_template")
58
60
  autoload :AskType, Project.project_filepath("forms/questions/ask_type")
59
61
  autoload :AskRegistration, Project.project_filepath("forms/questions/ask_registration")
60
62
  end
@@ -87,6 +89,16 @@ module Extension
87
89
  autoload :Default, Project.project_filepath("models/specification_handlers/default")
88
90
  end
89
91
 
92
+ module ServerConfig
93
+ autoload :Base, Project.project_filepath("models/server_config/base")
94
+ autoload :Development, Project.project_filepath("models/server_config/development")
95
+ autoload :DevelopmentEntries, Project.project_filepath("models/server_config/development_entries")
96
+ autoload :DevelopmentRenderer, Project.project_filepath("models/server_config/development_renderer")
97
+ autoload :Extension, Project.project_filepath("models/server_config/extension")
98
+ autoload :Root, Project.project_filepath("models/server_config/root")
99
+ autoload :User, Project.project_filepath("models/server_config/user")
100
+ end
101
+
90
102
  autoload :App, Project.project_filepath("models/app")
91
103
  autoload :Registration, Project.project_filepath("models/registration")
92
104
  autoload :Version, Project.project_filepath("models/version")
@@ -96,6 +108,8 @@ module Extension
96
108
  autoload :LazySpecificationHandler, Project.project_filepath("models/lazy_specification_handler")
97
109
  autoload :NpmPackage, Project.project_filepath("models/npm_package")
98
110
  autoload :Product, Project.project_filepath("models/product")
111
+ autoload :DevelopmentServer, Project.project_filepath("models/development_server")
112
+ autoload :DevelopmentServerRequirements, Project.project_filepath("models/development_server_requirements")
99
113
  end
100
114
 
101
115
  autoload :ExtensionProjectKeys, Project.project_filepath("extension_project_keys")
@@ -12,6 +12,34 @@ module Extension
12
12
  NPM_BUILD_COMMAND = %w(run-script build)
13
13
 
14
14
  def call(_args, _command_name)
15
+ project = ExtensionProject.current(force_reload: true)
16
+ return run_new_flow(project) if supports_development_server?(project.specification_identifier)
17
+ run_legacy_flow
18
+ end
19
+
20
+ def self.help
21
+ ShopifyCli::Context.new.message("build.help", ShopifyCli::TOOL_NAME)
22
+ end
23
+
24
+ private
25
+
26
+ def run_new_flow(project)
27
+ Tasks::RunExtensionCommand.new(
28
+ type: project.specification_identifier.downcase,
29
+ command: "build"
30
+ ).call
31
+
32
+ @ctx.puts(@ctx.message("build.build_success_message"))
33
+ rescue => error
34
+ if error.message.include?("no such file or directory")
35
+ @ctx.abort(@ctx.message("build.directory_not_found"))
36
+ else
37
+ @ctx.debug(error)
38
+ @ctx.abort(@ctx.message("build.build_failure_message"))
39
+ end
40
+ end
41
+
42
+ def run_legacy_flow
15
43
  system = ShopifyCli::JsSystem.new(ctx: @ctx)
16
44
 
17
45
  CLI::UI::Frame.open(@ctx.message("build.frame_title", system.package_manager)) do
@@ -20,8 +48,8 @@ module Extension
20
48
  end
21
49
  end
22
50
 
23
- def self.help
24
- ShopifyCli::Context.new.message("build.help", ShopifyCli::TOOL_NAME)
51
+ def supports_development_server?(type)
52
+ Models::DevelopmentServerRequirements.supported?(type)
25
53
  end
26
54
  end
27
55
  end